dryad 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: 525db97ef5566a76098259f051be94ae2c572732db0e5f18b9acceba854d2dff
4
- data.tar.gz: ffa6440cbaac6a8bda53dca85e2a0a963f267c4ace9b060b35c86564b82af015
3
+ metadata.gz: 739e141a8bf7a1e15e275be41760a7ec3f7f4ca0e195c4dcb737e74020c6dbf0
4
+ data.tar.gz: 3292e6fe7eb94cc4b6c782599397bccd1ecb28ddca4f2565ee348369970c353e
5
5
  SHA512:
6
- metadata.gz: 4d2f5faf15c93ed44762a61afef719d93af01480fe7deff392330c7b327a006cc69a4159ff82f0de7e5de13472f33e6270e74f4db8795df4d96af7c87d29e26c
7
- data.tar.gz: fb2bb883193a16b9e6b3aab42c3c968c1e151182bde77aaad431748c6bb11395ad31e861ac011a14ccd5ecf779f3bb68dfecdba09f4ee4ab6d0adaba11bff10e
6
+ metadata.gz: b40ab646fc4cc3241efc6e2209da33e532d56e3ffabcf65c641b768fa80fab22d28c7393a482ac1095a15133aa6ecad728970d7b3568a5c33003d4de6f7923c9
7
+ data.tar.gz: 3d7e92830c098c8208a055207e4b898f8aabdb8fb1a2e5fe1cb9e40091dd8c057b1de7cf4ad5ede586d71e76814de7d2e41d9a4d86fbab15dc5e01bd8a8ed1ee
data/Gemfile.lock CHANGED
@@ -1,17 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dryad (0.2.3)
5
- dryad-cluster (= 0.2.3)
6
- dryad-consul (= 0.2.3)
7
- dryad-core (= 0.2.3)
8
- dryad-cluster (0.2.3)
4
+ dryad (0.2.4)
5
+ dryad-cluster (= 0.2.4)
6
+ dryad-consul (= 0.2.4)
7
+ dryad-core (= 0.2.4)
8
+ dryad-cluster (0.2.4)
9
9
  concurrent-ruby (~> 1.1, >= 1.1.5)
10
- dryad-core (= 0.2.3)
11
- dryad-consul (0.2.3)
10
+ dryad-consul (= 0.2.4)
11
+ dryad-core (= 0.2.4)
12
+ dryad-consul (0.2.4)
12
13
  diplomat (~> 2.2, >= 2.2.4)
13
- dryad-core (= 0.2.3)
14
- dryad-core (0.2.3)
14
+ dryad-core (= 0.2.4)
15
+ dryad-core (0.2.4)
15
16
 
16
17
  GEM
17
18
  remote: https://rubygems.org/
@@ -19,7 +20,7 @@ GEM
19
20
  concurrent-ruby (1.1.5)
20
21
  deep_merge (1.2.1)
21
22
  diff-lcs (1.3)
22
- diplomat (2.2.4)
23
+ diplomat (2.2.5)
23
24
  deep_merge (~> 1.0, >= 1.0.1)
24
25
  faraday (~> 0.9)
25
26
  faraday (0.15.4)
@@ -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
@@ -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"
@@ -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
@@ -1,8 +1,13 @@
1
1
  RSpec.describe Dryad::Cluster do
2
2
  before do
3
- Dryad.configure do |config|
4
- config.registry = 'Dryad::Consul::ServiceRegistry'
5
- end
3
+ config = OpenStruct.new({
4
+ consul: { host: "127.0.0.1", port: 8500 },
5
+ namespace: "growing-crm",
6
+ group: "staging",
7
+ registry: "Dryad::Consul::ServiceRegistry"
8
+ })
9
+ Dryad::Consul.configure_consul(config)
10
+ Dryad::Cluster.configuration = config
6
11
 
7
12
  @portal = Dryad::Core::Portal.new(
8
13
  schema: Dryad::Core::Schema::HTTP,
@@ -1,7 +1,5 @@
1
- ENV['DRYAD_CONFIG_FILE'] = File.expand_path("dummy/config/dryad.yml", __dir__)
2
-
3
1
  require "bundler/setup"
4
- require "dryad"
2
+ require "dryad/core"
5
3
  require "dryad/consul"
6
4
  require "dryad/cluster"
7
5
 
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dryad-consul (0.2.3)
4
+ dryad-consul (0.2.5)
5
5
  diplomat (~> 2.2, >= 2.2.4)
6
- dryad-core (= 0.2.3)
6
+ dryad-core (= 0.2.5)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  deep_merge (1.2.1)
12
12
  diff-lcs (1.3)
13
- diplomat (2.2.4)
13
+ diplomat (2.2.5)
14
14
  deep_merge (~> 1.0, >= 1.0.1)
15
15
  faraday (~> 0.9)
16
- dryad-core (0.2.3)
16
+ dryad-core (0.2.5)
17
17
  faraday (0.15.4)
18
18
  multipart-post (>= 1.2, < 3)
19
19
  multipart-post (2.1.1)
@@ -1,5 +1,5 @@
1
1
  require "diplomat"
2
- require "dryad"
2
+ require "dryad/core"
3
3
  require "dryad/consul/railtie" if defined?(Rails)
4
4
  require "dryad/consul/version"
5
5
  require "dryad/consul/service_client"
@@ -11,5 +11,13 @@ require "dryad/consul/config_provider"
11
11
  module Dryad
12
12
  module Consul
13
13
  class Error < StandardError; end
14
+ class << self
15
+ def configure_consul(configuration)
16
+ ::Diplomat.configure do |config|
17
+ config.url = "http://#{configuration.consul[:host]}:#{configuration.consul[:port]}"
18
+ config.options = { headers: { "X-Consul-Token" => configuration.consul[:token] } } if configuration.consul[:token]
19
+ end
20
+ end
21
+ end
14
22
  end
15
23
  end
@@ -1,12 +1,12 @@
1
1
  require "rails"
2
+ require "dryad"
2
3
 
3
4
  module Dryad
4
5
  module Consul
5
6
  class Railtie < Rails::Railtie
6
7
  initializer "dryad_consul.set_consul" do
7
- ::Diplomat.configure do |config|
8
- config.url = "http://#{Dryad.configuration.consul[:host]}:#{Dryad.configuration.consul[:port]}"
9
- config.options = { headers: { "X-Consul-Token" => Dryad.configuration.consul[:token] } } if Dryad.configuration.consul[:token]
8
+ ActiveSupport.on_load(:dryad_consul) do
9
+ Dryad::Consul.configure_consul(Dryad.configuration)
10
10
  end
11
11
  end
12
12
 
@@ -18,8 +18,8 @@ module Dryad
18
18
  ActiveRecord::Base.establish_connection(Rails.env.to_sym)
19
19
  rescue Dryad::Core::ConfigurationNotFound => e
20
20
  raise e
21
- rescue e
22
- puts e.message
21
+ rescue Exception => e
22
+ Rails.logger.warn e.message
23
23
  end
24
24
  end
25
25
  end
@@ -1,5 +1,5 @@
1
1
  module Dryad
2
2
  module Consul
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.5'
4
4
  end
5
5
  end
@@ -4,6 +4,8 @@ RSpec.describe Dryad::Consul do
4
4
  end
5
5
 
6
6
  it "has configured dependencies" do
7
+ config = OpenStruct.new({ consul: { host: "127.0.0.1", port: 8500 } })
8
+ Dryad::Consul.configure_consul(config)
7
9
  expect(::Diplomat.configuration.url).to eq("http://127.0.0.1:8500")
8
10
  end
9
11
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dryad-core (0.2.2)
4
+ dryad-core (0.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,11 +1,11 @@
1
- require "dryad/core/version"
2
- require "dryad/core/service_instance"
3
- require "dryad/core/service"
4
- require "dryad/core/portal"
5
- require "dryad/core/load_balancing"
6
- require "dryad/core/schema"
7
1
  require "dryad/core/config_desc"
8
2
  require "dryad/core/config_provider"
3
+ require "dryad/core/load_balancing"
4
+ require "dryad/core/portal"
5
+ require "dryad/core/schema"
6
+ require "dryad/core/service_instance"
7
+ require "dryad/core/service"
8
+ require "dryad/core/version"
9
9
 
10
10
  module Dryad
11
11
  module Core
@@ -1,5 +1,5 @@
1
1
  module Dryad
2
2
  module Core
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.5'
4
4
  end
5
5
  end
@@ -1,4 +1,13 @@
1
1
  RSpec.describe Dryad::Core do
2
+ it "raise configuration not found error" do
3
+ begin
4
+ raise Dryad::Core::ConfigurationNotFound, "not found config file."
5
+ rescue Dryad::Core::ConfigurationNotFound => e
6
+ expect(e).not_to be(nil)
7
+ expect(e.message).to eq("not found config file.")
8
+ end
9
+ end
10
+
2
11
  it "has a version number" do
3
12
  expect(Dryad::Core::VERSION).not_to be(nil)
4
13
  end
@@ -1,5 +1,5 @@
1
1
  require "bundler/setup"
2
- require "dryad"
2
+ require "dryad/core"
3
3
 
4
4
  RSpec.configure do |config|
5
5
  # Enable flags like --only-failures and --next-failure
data/lib/dryad/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dryad
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dryad
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,42 +16,42 @@ 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
27
  - !ruby/object:Gem::Dependency
28
28
  name: dryad-consul
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.3
33
+ version: 0.2.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.3
40
+ version: 0.2.5
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dryad-cluster
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.3
47
+ version: 0.2.5
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.3
54
+ version: 0.2.5
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -121,11 +121,11 @@ files:
121
121
  - dryad-cluster/bin/setup
122
122
  - dryad-cluster/dryad-cluster.gemspec
123
123
  - dryad-cluster/lib/dryad/cluster.rb
124
+ - dryad-cluster/lib/dryad/cluster/railtie.rb
124
125
  - dryad-cluster/lib/dryad/cluster/round_robin.rb
125
126
  - dryad-cluster/lib/dryad/cluster/version.rb
126
127
  - dryad-cluster/spec/dryad/cluster/round_robin_spec.rb
127
128
  - dryad-cluster/spec/dryad/cluster_spec.rb
128
- - dryad-cluster/spec/dummy/config/dryad.yml
129
129
  - dryad-cluster/spec/spec_helper.rb
130
130
  - dryad-consul/.gitignore
131
131
  - dryad-consul/.rspec
@@ -163,7 +163,6 @@ files:
163
163
  - dryad-core/bin/console
164
164
  - dryad-core/bin/setup
165
165
  - dryad-core/dryad-core.gemspec
166
- - dryad-core/lib/dryad.rb
167
166
  - dryad-core/lib/dryad/core.rb
168
167
  - dryad-core/lib/dryad/core/config_desc.rb
169
168
  - dryad-core/lib/dryad/core/config_provider.rb
@@ -180,7 +179,6 @@ files:
180
179
  - dryad-core/spec/dryad/core/service_instance_spec.rb
181
180
  - dryad-core/spec/dryad/core/service_spec.rb
182
181
  - dryad-core/spec/dryad/core_spec.rb
183
- - dryad-core/spec/dummy/config/dryad.yml
184
182
  - dryad-core/spec/spec_helper.rb
185
183
  - dryad.gemspec
186
184
  - lib/dryad.rb
@@ -1,15 +0,0 @@
1
- default: &default
2
- consul:
3
- host: localhost
4
- port: 8500
5
- group: staging
6
- registry: Dryad::Consul::ServiceRegistry
7
-
8
- development:
9
- <<: *default
10
-
11
- test:
12
- <<: *default
13
-
14
- production:
15
- <<: *default
@@ -1 +0,0 @@
1
- require "dryad/core"
@@ -1,15 +0,0 @@
1
- default: &default
2
- consul:
3
- host: localhost
4
- port: 8500
5
- group: staging
6
- registry: Dryad::Consul::ServiceRegistry
7
-
8
- development:
9
- <<: *default
10
-
11
- test:
12
- <<: *default
13
-
14
- production:
15
- <<: *default