dryad-cluster 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -4
- data/Gemfile.lock +7 -7
- data/dryad-cluster.gemspec +1 -0
- data/lib/dryad/cluster.rb +6 -3
- data/lib/dryad/cluster/railtie.rb +15 -0
- data/lib/dryad/cluster/version.rb +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5037b0674a12f45af60b75b602b6015d9c022f0f831f66d59ece83c5290ec9a7
|
4
|
+
data.tar.gz: ad2c8ecee5104327503916be66ef1a7a8ebc1529d9e531305f90fbeb9cdd2380
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78124d0349de01f2fe51b5ee57d79e83aa9cf455d2379df15b5bd882b9de8e17deaf612eff63d1f997f2a034d9adf482bce4931c782523bc584ef79895a06130
|
7
|
+
data.tar.gz: 50a44574a8df346f02d3996f10f7632f2e3857505f1bf2a7445413c0179603d31c244d19a5aa624c03f54dd0e5c2e66e738b3eb69a4156aad2ee766dfbd0946d
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dryad-cluster (0.2.
|
4
|
+
dryad-cluster (0.2.5)
|
5
5
|
concurrent-ruby (~> 1.1, >= 1.1.5)
|
6
|
-
dryad-
|
6
|
+
dryad-consul (= 0.2.5)
|
7
|
+
dryad-core (= 0.2.5)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
@@ -11,13 +12,13 @@ GEM
|
|
11
12
|
concurrent-ruby (1.1.5)
|
12
13
|
deep_merge (1.2.1)
|
13
14
|
diff-lcs (1.3)
|
14
|
-
diplomat (2.2.
|
15
|
+
diplomat (2.2.5)
|
15
16
|
deep_merge (~> 1.0, >= 1.0.1)
|
16
17
|
faraday (~> 0.9)
|
17
|
-
dryad-consul (0.2.
|
18
|
+
dryad-consul (0.2.5)
|
18
19
|
diplomat (~> 2.2, >= 2.2.4)
|
19
|
-
dryad-core (= 0.2.
|
20
|
-
dryad-core (0.2.
|
20
|
+
dryad-core (= 0.2.5)
|
21
|
+
dryad-core (0.2.5)
|
21
22
|
faraday (0.15.4)
|
22
23
|
multipart-post (>= 1.2, < 3)
|
23
24
|
multipart-post (2.1.1)
|
@@ -42,7 +43,6 @@ PLATFORMS
|
|
42
43
|
DEPENDENCIES
|
43
44
|
bundler (~> 2.0)
|
44
45
|
dryad-cluster!
|
45
|
-
dryad-consul
|
46
46
|
rake (~> 10.0)
|
47
47
|
rspec (~> 3.0)
|
48
48
|
|
data/dryad-cluster.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_dependency "dryad-core", Dryad::Cluster::VERSION
|
25
|
+
spec.add_dependency "dryad-consul", Dryad::Cluster::VERSION
|
25
26
|
spec.add_dependency "concurrent-ruby", "~> 1.1", ">= 1.1.5"
|
26
27
|
|
27
28
|
spec.add_development_dependency "bundler", "~> 2.0"
|
data/lib/dryad/cluster.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'concurrent'
|
2
|
-
require "dryad"
|
2
|
+
require "dryad/core"
|
3
|
+
require "dryad/consul"
|
4
|
+
require "dryad/cluster/railtie" if defined?(Rails)
|
3
5
|
require "dryad/cluster/version"
|
4
6
|
require "dryad/cluster/round_robin"
|
5
7
|
|
@@ -9,10 +11,11 @@ module Dryad
|
|
9
11
|
class NoServicesError < Error; end
|
10
12
|
|
11
13
|
class << self
|
14
|
+
attr_accessor :configuration
|
12
15
|
CLUSTERS = {}
|
13
16
|
|
14
17
|
def round_robin(schema, service_name)
|
15
|
-
groups = ['_global_',
|
18
|
+
groups = ['_global_', @configuration.group]
|
16
19
|
full_name = Dryad::Core::Service.full_name(schema, service_name)
|
17
20
|
if CLUSTERS[full_name].nil?
|
18
21
|
CLUSTERS[full_name] = Dryad::Cluster::RoundRobin.new
|
@@ -28,7 +31,7 @@ module Dryad
|
|
28
31
|
end
|
29
32
|
|
30
33
|
def sorted_instances(service_name, schema, groups)
|
31
|
-
registry = Object.const_get(
|
34
|
+
registry = Object.const_get(@configuration.registry)
|
32
35
|
sis = registry.service_instances(service_name, schema, groups)
|
33
36
|
sis.sort {|a, b| "#{a.address}:#{a.port}" <=> "#{b.address}:#{b.port}"}
|
34
37
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rails"
|
2
|
+
require "dryad"
|
3
|
+
|
4
|
+
module Dryad
|
5
|
+
module Cluster
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
initializer "dryad_cluster.set_config" do
|
8
|
+
ActiveSupport.on_load(:dryad_cluster) do
|
9
|
+
Dryad::Cluster.configuration = Dryad.configuration
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
ActiveSupport.run_load_hooks(:dryad_cluster, Cluster)
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dryad-cluster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pan Jie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dryad-core
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dryad-consul
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.5
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: concurrent-ruby
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +118,7 @@ files:
|
|
104
118
|
- bin/setup
|
105
119
|
- dryad-cluster.gemspec
|
106
120
|
- lib/dryad/cluster.rb
|
121
|
+
- lib/dryad/cluster/railtie.rb
|
107
122
|
- lib/dryad/cluster/round_robin.rb
|
108
123
|
- lib/dryad/cluster/version.rb
|
109
124
|
homepage: https://github.com/jack0pan/dryad.rb
|