Skip to content

Commit

Permalink
Merge pull request #59 from wallin/tls-support
Browse files Browse the repository at this point in the history
TLS support + peers protocol
  • Loading branch information
jhecking authored Mar 27, 2018
2 parents bc72c30 + bf73d4e commit 41718d9
Show file tree
Hide file tree
Showing 70 changed files with 3,141 additions and 716 deletions.
4 changes: 2 additions & 2 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--tty
--colour
--color
--format documentation
--require spec_helper
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ rvm:
- 2.5
- 2.4
- 2.3
- 2.2
- rbx-3
env:
global:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
Unreleased
==========

* **New Features**
* Support for peers protocol for cluster discovery. Requires Aerospike server version 3.10 or later. Thanks to [@wallin](https://github.com/wallin) of [castle.io](https://castle.io/)! [[#59]](https://github.com/aerospike/aerospike-client-ruby/pull/59)
* Support for TLS encryption support for client <-> server connections. Requires Aerospike Enterprise Edition version 3.11 or later. Thanks to [@wallin](https://github.com/wallin) of [castle.io](https://castle.io/)! [[#59]](https://github.com/aerospike/aerospike-client-ruby/pull/59)

* **Bug Fixes**
* Fix min./max. boundary check for Integer bin values and improve performance. Thanks to [@wallin](https://github.com/wallin) of [castle.io](https://castle.io/)! [[#60]](https://github.com/aerospike/aerospike-client-ruby/pull/60)

* **Updates**
* Update minimum required Ruby version to v2.3.

v2.5.1 / 2018-01-25
===================

Expand Down
13 changes: 10 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ group :development do
end

gem 'rake'
gem "jruby-openssl", :platforms => :jruby
gem 'msgpack-jruby', :require => 'msgpack', :platforms => :jruby
gem 'msgpack', '~> 1.0', :platforms => [:mri, :rbx]
gem 'bcrypt'

platforms :mri, :rbx do
gem 'msgpack', '~> 1.0'
gem 'openssl'
end

platforms :jruby do
gem 'msgpack-jruby', require: 'msgpack'
gem 'jruby-openssl'
end

gemspec
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

An Aerospike library for Ruby.

This library is compatible with Ruby 2.2+ and supports Linux, Mac OS X and various other BSDs.
This library is compatible with Ruby 2.3+ and supports Linux, Mac OS X and various other BSDs.

- [Usage](#Usage)
- [Prerequisites](#Prerequisites)
Expand Down Expand Up @@ -61,7 +61,7 @@ Details about the API are available in the [`docs`](docs) directory.
<a name="Prerequisites"></a>
## Prerequisites

[Ruby](https://ruby-lang.org) version v2.2+ is required.
[Ruby](https://ruby-lang.org) version v2.3+ is required.

Aerospike Ruby client implements the wire protocol, and does not depend on the C client.
It is thread friendly.
Expand All @@ -81,7 +81,7 @@ Supported operating systems:

### Installation from source

1. Install Ruby 2.2+
1. Install Ruby 2.3+
2. Install RubyGems
3. Install Bundler: ```gem install bundler```
4. Install dependencies: ```bundler install```
Expand Down
2 changes: 1 addition & 1 deletion aerospike.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.license = "Apache-2.0"
s.files = Dir.glob("lib/**/*") + %w(CHANGELOG.md LICENSE README.md)
s.require_path = "lib"
s.required_ruby_version = '>= 2.2.0'
s.required_ruby_version = '>= 2.3.0'
s.post_install_message = "Thank you for using Aerospike!\nYou can report issues on github.com/aerospike/aerospike-client-ruby"
s.add_dependency("msgpack", '~> 1.0')
s.add_dependency("bcrypt", '~> 3.1')
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- '*_spec.rb'
39 changes: 33 additions & 6 deletions lib/aerospike.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# encoding: utf-8
# Copyright 2014-2017 Aerospike, Inc.
# Copyright 2014-2018 Aerospike, Inc.
#
# Portions may be licensed to Aerospike, Inc. under one or more contributor
# license agreements.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at http:#www.apache.org/licenses/LICENSE-2.0
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
Expand All @@ -29,7 +31,9 @@
require 'aerospike/utils/packer'
require 'aerospike/utils/unpacker'
require 'aerospike/utils/buffer'
require 'aerospike/utils/string_parser'
require 'aerospike/host'
require 'aerospike/host/parse'
require 'aerospike/loggable'
require 'aerospike/record'
require 'aerospike/result_code'
Expand Down Expand Up @@ -77,13 +81,36 @@
require 'aerospike/policy/commit_level'
require 'aerospike/policy/admin_policy'

require 'aerospike/cluster/connection'
require 'aerospike/cluster/cluster'
require 'aerospike/cluster/node_validator'
require 'aerospike/socket/base'
require 'aerospike/socket/ssl'
require 'aerospike/socket/tcp'

require 'aerospike/connection/authenticate'
require 'aerospike/connection/create'

require 'aerospike/cluster'
require 'aerospike/cluster/create_connection'
require 'aerospike/cluster/partition'
require 'aerospike/cluster/node'
require 'aerospike/cluster/find_node'
require 'aerospike/cluster/partition_tokenizer_new'
require 'aerospike/cluster/partition_tokenizer_old'
require 'aerospike/node'
require 'aerospike/node/generation'
require 'aerospike/node/refresh/failed'
require 'aerospike/node/refresh/friends'
require 'aerospike/node/refresh/info'
require 'aerospike/node/refresh/partitions'
require 'aerospike/node/refresh/peers'
require 'aerospike/node/refresh/reset'
require 'aerospike/node/verify/cluster_name'
require 'aerospike/node/verify/name'
require 'aerospike/node/verify/partition_generation'
require 'aerospike/node/verify/peers_generation'
require 'aerospike/node_validator'
require 'aerospike/peer'
require 'aerospike/peers'
require 'aerospike/peers/fetch'
require 'aerospike/peers/parse'
require 'aerospike/info'
require 'aerospike/udf'
require 'aerospike/bin'
Expand Down
35 changes: 9 additions & 26 deletions lib/aerospike/aerospike_exception.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# encoding: utf-8
# Copyright 2014-2017 Aerospike, Inc.
# Copyright 2014-2018 Aerospike, Inc.
#
# Portions may be licensed to Aerospike, Inc. under one or more contributor
# license agreements.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at http:#www.apache.org/licenses/LICENSE-2.0
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
Expand All @@ -17,95 +19,76 @@
require 'aerospike/result_code'

module Aerospike

module Exceptions

class Aerospike < StandardError

attr_reader :result_code

def initialize(result_code, message = nil)
@result_code = result_code
message ||= ResultCode.message(result_code)
super(message)

self
end

end

class Timeout < Aerospike

attr_reader :timeout, :iterations, :failed_nodes, :failed_connections

def initialize(timeout, iterations, failed_nodes=nil, failed_connections=nil)

@timeout = timeout
@iterations = iterations
@failed_nodes = failed_nodes
@failed_connections = failed_connections

super(ResultCode::TIMEOUT)

end
end

class InvalidCredentials < Aerospike
def initialize(msg = nil)
super(ResultCode::NOT_AUTHENTICATED, msg)
end
end

class Serialize < Aerospike

def initialize(msg=nil)
super(ResultCode::SERIALIZE_ERROR, msg)
end

end

class Parse < Aerospike

def initialize(msg=nil)
super(ResultCode::PARSE_ERROR, msg)
end

end

class Connection < Aerospike

def initialize(msg=nil)
super(ResultCode::SERVER_NOT_AVAILABLE, msg)
end

end

class InvalidNode < Aerospike

def initialize(msg=nil)
super(ResultCode::INVALID_NODE_ERROR, msg)
end

end

class ScanTerminated < Aerospike

def initialize(msg=nil)
super(ResultCode::SCAN_TERMINATED, msg)
end

end

class QueryTerminated < Aerospike

def initialize(msg=nil)
super(ResultCode::QUERY_TERMINATED, msg)
end

end

class CommandRejected < Aerospike

def initialize(msg=nil)
super(ResultCode::COMMAND_REJECTED, msg)
end

end

end
end
29 changes: 7 additions & 22 deletions lib/aerospike/client.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# encoding: utf-8
# Copyright 2014-2017 Aerospike, Inc.
# Copyright 2014-2018 Aerospike, Inc.
#
# Portions may be licensed to Aerospike, Inc. under one or more contributor
# license agreements.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at http:#www.apache.org/licenses/LICENSE-2.0
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
Expand Down Expand Up @@ -46,9 +48,9 @@ def initialize(hosts = nil, policy: ClientPolicy.new, connect: true)
@default_query_policy = QueryPolicy.new
@default_admin_policy = QueryPolicy.new

hosts = parse_hosts(hosts || ENV["AEROSPIKE_HOSTS"] || "localhost")
hosts = ::Aerospike::Host::Parse.(hosts || ENV['AEROSPIKE_HOSTS'] || 'localhost')
policy = create_policy(policy, ClientPolicy)
@cluster = Cluster.new(policy, *hosts)
@cluster = Cluster.new(policy, hosts)
@cluster.add_cluster_config_change_listener(self)

self.connect if connect
Expand Down Expand Up @@ -88,7 +90,7 @@ def nodes
# Returns list of active server node names in the cluster.

def node_names
@cluster.nodes.map(&:get_name)
@cluster.nodes.map(&:name)
end

def supports_feature?(feature)
Expand Down Expand Up @@ -826,23 +828,6 @@ def create_policy(policy, policy_klass)
end
end

def parse_hosts(hosts)
case hosts
when Host
[hosts]
when Array
hosts
when String
hosts.split(?,).map { |host|
(addr, port) = host.split(?:)
port ||= 3000
Host.new(addr, port.to_i)
}
else
fail TypeError, "hosts should be a Host object, an Array of Host objects, or a String"
end
end

def cluster=(cluster)
@cluster = cluster
end
Expand Down
Loading

0 comments on commit 41718d9

Please sign in to comment.