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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49215a5ff2b15fae0c400f02242e8aeabea3da6d2c3362ca595a894a15e3c23e
4
- data.tar.gz: 3c36c521649fd58aa1b2cf79963b35a6556a693f82e7dec984419f6638641503
3
+ metadata.gz: 5037b0674a12f45af60b75b602b6015d9c022f0f831f66d59ece83c5290ec9a7
4
+ data.tar.gz: ad2c8ecee5104327503916be66ef1a7a8ebc1529d9e531305f90fbeb9cdd2380
5
5
  SHA512:
6
- metadata.gz: 6cf023db097e0c91af9d49c4be222592ce5ab7287a43743ef1158f4cc37f2697f6b5059dd802ecdf2ac6cee0fce2c0f426a5263adb11adac21a6d008da5e5497
7
- data.tar.gz: 594d3f13d20523919c11543bf2db7dd7f933aabc2df314cbdb417d7d6badbb56a9c6ed84ac2c4ab59a4b002418b074221674b49732d6b90a70d44f1cb380ac20
6
+ metadata.gz: 78124d0349de01f2fe51b5ee57d79e83aa9cf455d2379df15b5bd882b9de8e17deaf612eff63d1f997f2a034d9adf482bce4931c782523bc584ef79895a06130
7
+ data.tar.gz: 50a44574a8df346f02d3996f10f7632f2e3857505f1bf2a7445413c0179603d31c244d19a5aa624c03f54dd0e5c2e66e738b3eb69a4156aad2ee766dfbd0946d
data/Gemfile CHANGED
@@ -2,7 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in dryad-cluster.gemspec
4
4
  gemspec
5
-
6
- group :test do
7
- gem 'dryad-consul'
8
- end
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dryad-cluster (0.2.3)
4
+ dryad-cluster (0.2.5)
5
5
  concurrent-ruby (~> 1.1, >= 1.1.5)
6
- dryad-core (= 0.2.3)
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.4)
15
+ diplomat (2.2.5)
15
16
  deep_merge (~> 1.0, >= 1.0.1)
16
17
  faraday (~> 0.9)
17
- dryad-consul (0.2.3)
18
+ dryad-consul (0.2.5)
18
19
  diplomat (~> 2.2, >= 2.2.4)
19
- dryad-core (= 0.2.3)
20
- dryad-core (0.2.3)
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
 
@@ -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_', Dryad.configuration.group]
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(Dryad.configuration.registry)
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
@@ -1,5 +1,5 @@
1
1
  module Dryad
2
2
  module Cluster
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.5'
4
4
  end
5
5
  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.3
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-03 00:00:00.000000000 Z
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.3
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.3
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