ruby_skynet 1.2.7 → 1.3.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -4
- data/Gemfile.lock +12 -23
- data/lib/ruby_skynet.rb +33 -2
- data/lib/ruby_skynet/client.rb +6 -12
- data/lib/ruby_skynet/connection.rb +11 -51
- data/lib/ruby_skynet/doozer/service_registry.rb +3 -14
- data/lib/ruby_skynet/static_service_registry.rb +75 -0
- data/lib/ruby_skynet/version.rb +1 -1
- data/lib/ruby_skynet/zookeeper/service_registry.rb +3 -14
- data/ruby_skynet.gemspec +25 -0
- data/test/client_test.rb +1 -1
- data/test/service_registry_test.rb +10 -4
- data/test/zookeeper_registry_test.rb +1 -1
- metadata +7 -6
- data/lib/ruby_skynet/service_registry.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c969a82d83df34cb54f6417180b098db0a83ccaa
|
4
|
+
data.tar.gz: de2482f4598ad614af99ae74122d91fbbc578233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9777072ab66461a26c5f32befd5e9d65cdcca68d34d0f0a71b66b91f2ac66d958adb2aceb06acba828d86436d65ad5aa64ff971a52eb474c736e895f8854e544
|
7
|
+
data.tar.gz: ced033f9f4c2987abbc6ae7c18f2044b8d01d9d5bac73f877feef12604936b96f6778ff3ab0fe1e20a9af4af40290388f2401f8b71034e07b36292d75bfb6f24
|
data/Gemfile
CHANGED
@@ -8,15 +8,13 @@ gem "rake"
|
|
8
8
|
gem "semantic_logger", ">= 2.1"
|
9
9
|
gem "resilient_socket"
|
10
10
|
# Doozer Client
|
11
|
-
gem "ruby_doozer"
|
11
|
+
#gem "ruby_doozer"
|
12
12
|
# Zookeeper Client
|
13
13
|
gem "zookeeper"
|
14
14
|
# Thread Safe Hash and Array
|
15
15
|
gem "thread_safe"
|
16
|
-
# Connection pool
|
17
|
-
gem "gene_pool"
|
18
16
|
# For looking up Service entries in Service Registry
|
19
17
|
gem "multi_json"
|
20
18
|
# Wire format when communicating with services
|
21
|
-
gem "bson"
|
19
|
+
gem "bson", '1.5.2'
|
22
20
|
gem "bson_ext", :platform => :ruby
|
data/Gemfile.lock
CHANGED
@@ -1,57 +1,46 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (4.0.
|
4
|
+
activesupport (4.0.2)
|
5
5
|
i18n (~> 0.6, >= 0.6.4)
|
6
6
|
minitest (~> 4.2)
|
7
7
|
multi_json (~> 1.3)
|
8
8
|
thread_safe (~> 0.1)
|
9
9
|
tzinfo (~> 0.3.37)
|
10
10
|
atomic (1.1.14)
|
11
|
-
bson (1.
|
12
|
-
bson_ext (1.
|
13
|
-
bson (
|
14
|
-
|
15
|
-
i18n (0.6.5)
|
11
|
+
bson (1.5.2)
|
12
|
+
bson_ext (1.5.2)
|
13
|
+
bson (= 1.5.2)
|
14
|
+
i18n (0.6.9)
|
16
15
|
minitest (4.7.5)
|
17
|
-
multi_json (1.8.
|
16
|
+
multi_json (1.8.2)
|
18
17
|
rake (10.1.0)
|
19
18
|
resilient_socket (0.5.0)
|
20
19
|
semantic_logger (>= 2.1)
|
21
|
-
|
22
|
-
gene_pool (>= 1.3.0)
|
23
|
-
multi_json (>= 1.6.1)
|
24
|
-
resilient_socket (>= 0.5.0)
|
25
|
-
ruby_protobuf (>= 0.4.11)
|
26
|
-
semantic_logger (>= 2.1)
|
27
|
-
sync_attr (>= 1.0.0)
|
28
|
-
ruby_protobuf (0.4.11)
|
29
|
-
semantic_logger (2.2.0)
|
20
|
+
semantic_logger (2.6.1)
|
30
21
|
sync_attr (>= 1.0)
|
31
22
|
thread_safe (>= 0.1.0)
|
32
23
|
shoulda (3.5.0)
|
33
24
|
shoulda-context (~> 1.0, >= 1.0.1)
|
34
25
|
shoulda-matchers (>= 1.4.1, < 3.0)
|
35
|
-
shoulda-context (1.1.
|
36
|
-
shoulda-matchers (2.
|
26
|
+
shoulda-context (1.1.6)
|
27
|
+
shoulda-matchers (2.4.0)
|
37
28
|
activesupport (>= 3.0.0)
|
38
29
|
sync_attr (1.0.0)
|
39
30
|
thread_safe (0.1.3)
|
40
31
|
atomic
|
41
|
-
tzinfo (0.3.
|
42
|
-
zookeeper (1.4.
|
32
|
+
tzinfo (0.3.38)
|
33
|
+
zookeeper (1.4.7)
|
43
34
|
|
44
35
|
PLATFORMS
|
45
36
|
ruby
|
46
37
|
|
47
38
|
DEPENDENCIES
|
48
|
-
bson
|
39
|
+
bson (= 1.5.2)
|
49
40
|
bson_ext
|
50
|
-
gene_pool
|
51
41
|
multi_json
|
52
42
|
rake
|
53
43
|
resilient_socket
|
54
|
-
ruby_doozer
|
55
44
|
semantic_logger (>= 2.1)
|
56
45
|
shoulda
|
57
46
|
thread_safe
|
data/lib/ruby_skynet.rb
CHANGED
@@ -11,8 +11,39 @@ module RubySkynet
|
|
11
11
|
autoload :Client, 'ruby_skynet/client'
|
12
12
|
autoload :Service, 'ruby_skynet/service'
|
13
13
|
autoload :Server, 'ruby_skynet/server'
|
14
|
-
autoload :
|
15
|
-
|
14
|
+
autoload :Zookeeper, 'ruby_skynet/zookeeper'
|
15
|
+
end
|
16
|
+
|
17
|
+
# Autodetect if Zookeeper gem is loaded, otherwise look for Doozer
|
18
|
+
module RubySkynet
|
19
|
+
begin
|
20
|
+
require 'zookeeper'
|
21
|
+
require 'zookeeper/client'
|
22
|
+
require 'ruby_skynet/zookeeper/service_registry'
|
23
|
+
# Monkey-patch so that the Zookeeper JRuby code can handle nil values in Zookeeper
|
24
|
+
require 'ruby_skynet/zookeeper/extensions/java_base' if defined?(::JRUBY_VERSION)
|
25
|
+
|
26
|
+
# Shortcuts to loaded Registry classes
|
27
|
+
ServiceRegistry = RubySkynet::Zookeeper::ServiceRegistry
|
28
|
+
CachedRegistry = RubySkynet::Zookeeper::CachedRegistry
|
29
|
+
Registry = RubySkynet::Zookeeper::Registry
|
30
|
+
rescue LoadError
|
31
|
+
begin
|
32
|
+
require 'ruby_doozer'
|
33
|
+
require 'ruby_skynet/doozer/service_registry'
|
34
|
+
|
35
|
+
# Shortcuts to loaded Registry classes
|
36
|
+
ServiceRegistry = RubySkynet::Doozer::ServiceRegistry
|
37
|
+
CachedRegistry = Doozer::CachedRegistry
|
38
|
+
Registry = Doozer::Registry
|
39
|
+
rescue LoadError
|
40
|
+
require 'ruby_skynet/static_service_registry'
|
41
|
+
|
42
|
+
# Use Static Service Registry
|
43
|
+
ServiceRegistry = RubySkynet::StaticServiceRegistry
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
16
47
|
end
|
17
48
|
|
18
49
|
if defined?(Rails)
|
data/lib/ruby_skynet/client.rb
CHANGED
@@ -83,20 +83,14 @@ module RubySkynet
|
|
83
83
|
# Skynet requires BSON RPC Calls to have the following format:
|
84
84
|
# https://github.com/skynetservices/skynet/blob/master/protocol.md
|
85
85
|
request_id = BSON::ObjectId.new.to_s
|
86
|
+
|
87
|
+
# Obtain list of servers implementing this service in order of priority
|
88
|
+
servers = ::RubySkynet.service_registry.servers_for(skynet_name, skynet_version, skynet_region)
|
89
|
+
|
86
90
|
logger.tagged request_id do
|
87
91
|
logger.benchmark_info "Called Skynet Service: #{skynet_name}.#{method_name}" do
|
88
|
-
|
89
|
-
|
90
|
-
begin
|
91
|
-
Connection.with_connection(::RubySkynet.service_registry.server_for(skynet_name, skynet_version, skynet_region), connection_params) do |connection|
|
92
|
-
connection.rpc_call(request_id, skynet_name, method_name, parameters)
|
93
|
-
end
|
94
|
-
rescue ResilientSocket::ConnectionFailure => exc
|
95
|
-
if (retries < 3) && exc.cause.is_a?(Errno::ECONNREFUSED)
|
96
|
-
retries += 1
|
97
|
-
retry
|
98
|
-
end
|
99
|
-
# TODO rescue ServiceUnavailable retry x times until the service becomes available
|
92
|
+
Connection.with_connection(servers, connection_params) do |connection|
|
93
|
+
connection.rpc_call(request_id, skynet_name, method_name, parameters)
|
100
94
|
end
|
101
95
|
end
|
102
96
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'bson'
|
2
|
-
require 'gene_pool'
|
3
2
|
require 'thread_safe'
|
4
3
|
require 'resilient_socket'
|
5
4
|
require 'sync_attr'
|
@@ -17,20 +16,6 @@ module RubySkynet
|
|
17
16
|
# Returns the underlying socket being used by a Connection instance
|
18
17
|
attr_reader :socket
|
19
18
|
|
20
|
-
# Default Pool configuration
|
21
|
-
sync_cattr_accessor :pool_config do
|
22
|
-
{
|
23
|
-
:pool_size => 30, # Maximum number of connections to any one server
|
24
|
-
:warn_timeout => 2, # Log a warning if no connections are available after the :warn_timeout seconds
|
25
|
-
:timeout => 10, # Raise a Timeout exception if no connections are available after the :timeout seconds
|
26
|
-
:idle_timeout => 600, # Renew a connection if it has been idle for this period of time
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
# For each server there is a connection pool keyed on the
|
31
|
-
# server address: 'host:port'
|
32
|
-
@@connection_pools = ThreadSafe::Hash.new
|
33
|
-
|
34
19
|
# Returns a new RubySkynet connection to the server
|
35
20
|
#
|
36
21
|
# Parameters:
|
@@ -50,8 +35,8 @@ module RubySkynet
|
|
50
35
|
# :connect_retry_interval [Float]
|
51
36
|
# Number of seconds between connection retry attempts after the first failed attempt
|
52
37
|
# Default: 0.5
|
53
|
-
def initialize(
|
54
|
-
|
38
|
+
def initialize(servers, params = {})
|
39
|
+
params = params.dup
|
55
40
|
|
56
41
|
# User configurable options
|
57
42
|
params[:read_timeout] ||= 60
|
@@ -95,8 +80,8 @@ module RubySkynet
|
|
95
80
|
end
|
96
81
|
|
97
82
|
# To prevent strange issues if user incorrectly supplies server names
|
98
|
-
params.delete(:
|
99
|
-
params[:
|
83
|
+
params.delete(:server)
|
84
|
+
params[:servers] = servers
|
100
85
|
|
101
86
|
@socket = ResilientSocket::TCPClient.new(params)
|
102
87
|
end
|
@@ -209,44 +194,19 @@ module RubySkynet
|
|
209
194
|
|
210
195
|
# Execute the supplied block with a connection from the pool
|
211
196
|
def self.with_connection(server, params={}, &block)
|
212
|
-
|
197
|
+
conn = nil
|
198
|
+
begin
|
199
|
+
conn = new(server, params)
|
200
|
+
block.call(conn)
|
201
|
+
ensure
|
202
|
+
conn.close if conn
|
203
|
+
end
|
213
204
|
end
|
214
205
|
|
215
206
|
def close
|
216
207
|
@socket.close if @socket
|
217
208
|
end
|
218
209
|
|
219
|
-
########################
|
220
|
-
protected
|
221
|
-
|
222
|
-
# Returns a new connection pool for the specified server
|
223
|
-
def self.new_connection_pool(server, params={})
|
224
|
-
# Connection pool configuration options
|
225
|
-
config = pool_config.dup
|
226
|
-
|
227
|
-
logger = SemanticLogger::Logger.new("#{self.class.name} [#{server}]")
|
228
|
-
|
229
|
-
# Method to call to close idle connections
|
230
|
-
config[:close_proc] = :close
|
231
|
-
config[:logger] = logger
|
232
|
-
|
233
|
-
pool = GenePool.new(pool_config) do
|
234
|
-
new(server, params)
|
235
|
-
end
|
236
|
-
|
237
|
-
# Cleanup corresponding connection pool when a server terminates
|
238
|
-
RubySkynet.service_registry.on_server_removed(server) do
|
239
|
-
pool = @@connection_pools.delete(server)
|
240
|
-
# Cannot close all the connections since they could still be in use
|
241
|
-
pool.remove_idle(0) if pool
|
242
|
-
#pool.close if pool
|
243
|
-
logger.debug "Connection pool released"
|
244
|
-
end
|
245
|
-
|
246
|
-
pool
|
247
|
-
end
|
248
|
-
|
249
210
|
end
|
250
|
-
|
251
211
|
end
|
252
212
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'semantic_logger'
|
2
2
|
require 'thread_safe'
|
3
|
-
require 'gene_pool'
|
4
3
|
require 'resolv'
|
5
4
|
|
6
5
|
#
|
@@ -62,18 +61,6 @@ module RubySkynet
|
|
62
61
|
@registry.delete("#{name}/#{version}/#{region}/#{hostname}/#{port}")
|
63
62
|
end
|
64
63
|
|
65
|
-
# Return a server that implements the specified service
|
66
|
-
def server_for(name, version='*', region=RubySkynet.region)
|
67
|
-
if servers = servers_for(name, version, region)
|
68
|
-
# Randomly select one of the servers offering the service
|
69
|
-
servers[rand(servers.size)]
|
70
|
-
else
|
71
|
-
msg = "No servers available for service: #{name} with version: #{version} in region: #{region}"
|
72
|
-
logger.warn msg
|
73
|
-
raise ServiceUnavailable.new(msg)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
64
|
# Returns [Array<String>] a list of servers implementing the requested service
|
78
65
|
def servers_for(name, version='*', region=RubySkynet.region)
|
79
66
|
if version == '*'
|
@@ -86,9 +73,11 @@ module RubySkynet
|
|
86
73
|
end
|
87
74
|
end
|
88
75
|
end
|
89
|
-
if server_infos = @cache["#{name}/#{version}/#{region}"]
|
76
|
+
servers = if server_infos = @cache["#{name}/#{version}/#{region}"]
|
90
77
|
server_infos.first.servers
|
91
78
|
end
|
79
|
+
raise ServiceUnavailable.new("No servers available for service: #{name} with version: #{version} in region: #{region}") unless servers
|
80
|
+
servers
|
92
81
|
end
|
93
82
|
|
94
83
|
# Invokes registered callbacks when a specific server is shutdown or terminates
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'semantic_logger'
|
2
|
+
require 'thread_safe'
|
3
|
+
|
4
|
+
#
|
5
|
+
# RubySkynet Sevices Registry
|
6
|
+
#
|
7
|
+
# Loads a list of all services and which servers they are available on from a
|
8
|
+
# static YAML file
|
9
|
+
#
|
10
|
+
# Format of the YAML file
|
11
|
+
# key: [String] "<name>/<version>/<region>"
|
12
|
+
# value: [Array<String>] 'host:port', 'host:port'
|
13
|
+
|
14
|
+
#
|
15
|
+
module RubySkynet
|
16
|
+
class StaticServiceRegistry
|
17
|
+
include SemanticLogger::Loggable
|
18
|
+
|
19
|
+
# Create a service registry
|
20
|
+
def initialize(services = {})
|
21
|
+
@services = services
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns the Service Registry as a Hash
|
25
|
+
def to_h
|
26
|
+
@services.dup
|
27
|
+
end
|
28
|
+
|
29
|
+
# Register the supplied service at this Skynet Server host and Port
|
30
|
+
# Returns the UUID for the service that was created
|
31
|
+
def register_service(name, version, region, hostname, port)
|
32
|
+
server = "#{hostname}:#{port}"
|
33
|
+
key = "#{name}/#{version}/#{region}"
|
34
|
+
(@services[key] ||= []) << server
|
35
|
+
key
|
36
|
+
end
|
37
|
+
|
38
|
+
# Deregister the supplied service from the Registry
|
39
|
+
def deregister_service(name, version, region, hostname, port)
|
40
|
+
server = "#{hostname}:#{port}"
|
41
|
+
key = "#{name}/#{version}/#{region}"
|
42
|
+
if servers = @services[key]
|
43
|
+
servers.delete_if {|s| s == server}
|
44
|
+
@services.delete(key) if servers.count == 0
|
45
|
+
end
|
46
|
+
key
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns [Array<String>] a list of servers implementing the requested service
|
50
|
+
def servers_for(name, version='*', region=RubySkynet.region)
|
51
|
+
if version == '*'
|
52
|
+
# Find the highest version for the named service in this region
|
53
|
+
version = -1
|
54
|
+
@services.keys.each do |key|
|
55
|
+
if match = key.match(/#{name}\/(\d+)\/#{region}/)
|
56
|
+
ver = match[1].to_i
|
57
|
+
version = ver if ver > version
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
servers = @services["#{name}/#{version}/#{region}"]
|
62
|
+
raise ServiceUnavailable.new("No servers available for service: #{name} with version: #{version} in region: #{region}") unless servers
|
63
|
+
servers
|
64
|
+
end
|
65
|
+
|
66
|
+
# Invokes registered callbacks when a specific server is shutdown or terminates
|
67
|
+
# Not when a server de-registers itself
|
68
|
+
# The callback will only be called once and will need to be re-registered
|
69
|
+
# after being called if future callbacks are required for that server
|
70
|
+
def on_server_removed(server, &block)
|
71
|
+
#nop
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
data/lib/ruby_skynet/version.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'semantic_logger'
|
2
2
|
require 'thread_safe'
|
3
|
-
require 'gene_pool'
|
4
3
|
require 'resolv'
|
5
4
|
|
6
5
|
#
|
@@ -76,18 +75,6 @@ module RubySkynet
|
|
76
75
|
uuid
|
77
76
|
end
|
78
77
|
|
79
|
-
# Return a server that implements the specified service
|
80
|
-
def server_for(name, version='*', region=RubySkynet.region)
|
81
|
-
if servers = servers_for(name, version, region)
|
82
|
-
# Randomly select one of the servers offering the service
|
83
|
-
servers[rand(servers.size)]
|
84
|
-
else
|
85
|
-
msg = "No servers available for service: #{name} with version: #{version} in region: #{region}"
|
86
|
-
logger.warn msg
|
87
|
-
raise ServiceUnavailable.new(msg)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
78
|
# Returns [Array<String>] a list of servers implementing the requested service
|
92
79
|
def servers_for(name, version='*', region=RubySkynet.region)
|
93
80
|
if version == '*'
|
@@ -100,9 +87,11 @@ module RubySkynet
|
|
100
87
|
end
|
101
88
|
end
|
102
89
|
end
|
103
|
-
if server_infos = @cache["#{name}/#{version}/#{region}"]
|
90
|
+
servers = if server_infos = @cache["#{name}/#{version}/#{region}"]
|
104
91
|
server_infos.first.servers
|
105
92
|
end
|
93
|
+
raise ServiceUnavailable.new("No servers available for service: #{name} with version: #{version} in region: #{region}") unless servers
|
94
|
+
servers
|
106
95
|
end
|
107
96
|
|
108
97
|
# Invokes registered callbacks when a specific server is shutdown or terminates
|
data/ruby_skynet.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
3
|
+
|
4
|
+
require 'date'
|
5
|
+
require 'ruby_skynet/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'ruby_skynet'
|
9
|
+
spec.version = RubySkynet::VERSION
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
11
|
+
spec.authors = ['Reid Morrison']
|
12
|
+
spec.email = ['reidmo@gmail.com']
|
13
|
+
spec.homepage = 'https://github.com/ClarityServices/ruby_skynet'
|
14
|
+
spec.date = Date.today.to_s
|
15
|
+
spec.summary = "Skynet Ruby Client"
|
16
|
+
spec.description = "Ruby Client for invoking Skynet services"
|
17
|
+
spec.files = Dir.glob("lib/**/*") + Dir.glob("examples/**/*.rb") + %w(LICENSE.txt README.md)
|
18
|
+
spec.license = "Apache License V2.0"
|
19
|
+
spec.has_rdoc = true
|
20
|
+
spec.add_dependency 'semantic_logger', '>= 2.6.1'
|
21
|
+
spec.add_dependency 'resilient_socket', '>= 0.5.0'
|
22
|
+
spec.add_dependency 'sync_attr', '>= 1.0.0'
|
23
|
+
spec.add_dependency 'bson', '>= 1.5.2'
|
24
|
+
spec.add_dependency 'thread_safe'
|
25
|
+
end
|
data/test/client_test.rb
CHANGED
@@ -50,7 +50,7 @@ class ClientTest < Test::Unit::TestCase
|
|
50
50
|
client = RubySkynet::Client.new('SomeService','*','ClientTest')
|
51
51
|
client.call(:test, :hello => 'there')
|
52
52
|
end
|
53
|
-
assert_match /No servers available for service: SomeService with version:
|
53
|
+
assert_match /No servers available for service: SomeService with version: -1 in region: ClientTest/, exception.message
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
@@ -42,7 +42,7 @@ class ServiceRegistryTest < Test::Unit::TestCase
|
|
42
42
|
# Allow time for registry callback that service was deregistered
|
43
43
|
sleep 0.1
|
44
44
|
# No servers should be in the local registry
|
45
|
-
# assert_equal nil, RubySkynet.service_registry.servers_for(@service_name, @version, @region)
|
45
|
+
# assert_equal nil, RubySkynet.service_registry.servers_for(@service_name, @version, @region)
|
46
46
|
end
|
47
47
|
|
48
48
|
should "find server using exact match" do
|
@@ -83,15 +83,21 @@ class ServiceRegistryTest < Test::Unit::TestCase
|
|
83
83
|
end
|
84
84
|
|
85
85
|
should "return nil when service not found" do
|
86
|
-
|
86
|
+
assert_raise RubySkynet::ServiceUnavailable do
|
87
|
+
RubySkynet.service_registry.servers_for('MissingService', @version, @region)
|
88
|
+
end
|
87
89
|
end
|
88
90
|
|
89
91
|
should "return nil when version not found" do
|
90
|
-
|
92
|
+
assert_raise RubySkynet::ServiceUnavailable do
|
93
|
+
RubySkynet.service_registry.servers_for(@service_name, @version+1, @region)
|
94
|
+
end
|
91
95
|
end
|
92
96
|
|
93
97
|
should "return nil when region not found" do
|
94
|
-
|
98
|
+
assert_raise RubySkynet::ServiceUnavailable do
|
99
|
+
RubySkynet.service_registry.servers_for(@service_name, @version, 'OtherRegion')
|
100
|
+
end
|
95
101
|
end
|
96
102
|
end
|
97
103
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_skynet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic_logger
|
@@ -122,7 +122,7 @@ files:
|
|
122
122
|
- lib/ruby_skynet/ruby_skynet.rb
|
123
123
|
- lib/ruby_skynet/server.rb
|
124
124
|
- lib/ruby_skynet/service.rb
|
125
|
-
- lib/ruby_skynet/
|
125
|
+
- lib/ruby_skynet/static_service_registry.rb
|
126
126
|
- lib/ruby_skynet/version.rb
|
127
127
|
- lib/ruby_skynet/zookeeper.rb
|
128
128
|
- lib/ruby_skynet/zookeeper/cached_registry.rb
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/ruby_skynet/zookeeper/json/serializer.rb
|
132
132
|
- lib/ruby_skynet/zookeeper/registry.rb
|
133
133
|
- lib/ruby_skynet/zookeeper/service_registry.rb
|
134
|
+
- ruby_skynet.gemspec
|
134
135
|
- test/client_test.rb
|
135
136
|
- test/service_registry_test.rb
|
136
137
|
- test/service_test.rb
|
@@ -150,12 +151,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
151
|
version: '0'
|
151
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
153
|
requirements:
|
153
|
-
- - '
|
154
|
+
- - '>'
|
154
155
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
156
|
+
version: 1.3.1
|
156
157
|
requirements: []
|
157
158
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.1.11
|
159
160
|
signing_key:
|
160
161
|
specification_version: 4
|
161
162
|
summary: Skynet Ruby Client
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# Define RubySkynet::ServiceRegistry based on whether the ZooKeeper or Doozer gem is present
|
2
|
-
module RubySkynet
|
3
|
-
begin
|
4
|
-
require 'zookeeper'
|
5
|
-
require 'zookeeper/client'
|
6
|
-
require 'ruby_skynet/zookeeper/service_registry'
|
7
|
-
# Monkey-patch so that the Zookeeper JRuby code can handle nil values in Zookeeper
|
8
|
-
require 'ruby_skynet/zookeeper/extensions/java_base' if defined?(::JRUBY_VERSION)
|
9
|
-
ServiceRegistry = RubySkynet::Zookeeper::ServiceRegistry
|
10
|
-
CachedRegistry = RubySkynet::Zookeeper::CachedRegistry
|
11
|
-
Registry = RubySkynet::Zookeeper::Registry
|
12
|
-
rescue LoadError
|
13
|
-
begin
|
14
|
-
require 'ruby_doozer'
|
15
|
-
require 'ruby_skynet/doozer/service_registry'
|
16
|
-
rescue LoadError
|
17
|
-
raise LoadError, "Must gem install either 'zookeeper' or 'ruby_doozer'. 'zookeeper' is recommended"
|
18
|
-
end
|
19
|
-
ServiceRegistry = RubySkynet::Doozer::ServiceRegistry
|
20
|
-
CachedRegistry = Doozer::CachedRegistry
|
21
|
-
Registry = Doozer::Registry
|
22
|
-
end
|
23
|
-
end
|