dryad 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/dryad-cluster/Gemfile.lock +5 -5
- data/dryad-cluster/lib/dryad/cluster/version.rb +1 -1
- data/dryad-cluster/lib/dryad/cluster.rb +2 -2
- data/dryad-cluster/spec/dryad/cluster_spec.rb +4 -0
- data/dryad-consul/Gemfile.lock +3 -3
- data/dryad-consul/lib/dryad/consul/railtie.rb +28 -0
- data/dryad-consul/lib/dryad/consul/version.rb +1 -1
- data/dryad-consul/lib/dryad/consul.rb +1 -5
- data/dryad-consul/spec/dryad/consul_spec.rb +1 -1
- data/dryad-core/Gemfile.lock +1 -1
- data/dryad-core/lib/dryad/core/version.rb +1 -1
- data/dryad-core/lib/dryad.rb +0 -45
- data/dryad-core/spec/spec_helper.rb +0 -5
- data/dryad.gemspec +1 -0
- data/lib/dryad/railtie.rb +14 -0
- data/lib/dryad/version.rb +1 -1
- data/lib/dryad.rb +39 -0
- metadata +13 -11
- data/dryad-core/spec/dryad_spec.rb +0 -21
- /data/{dryad-core/lib → lib}/dryad/configuration.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 525db97ef5566a76098259f051be94ae2c572732db0e5f18b9acceba854d2dff
|
4
|
+
data.tar.gz: ffa6440cbaac6a8bda53dca85e2a0a963f267c4ace9b060b35c86564b82af015
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d2f5faf15c93ed44762a61afef719d93af01480fe7deff392330c7b327a006cc69a4159ff82f0de7e5de13472f33e6270e74f4db8795df4d96af7c87d29e26c
|
7
|
+
data.tar.gz: fb2bb883193a16b9e6b3aab42c3c968c1e151182bde77aaad431748c6bb11395ad31e861ac011a14ccd5ecf779f3bb68dfecdba09f4ee4ab6d0adaba11bff10e
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dryad (0.2.
|
5
|
-
dryad-cluster (= 0.2.
|
6
|
-
dryad-consul (= 0.2.
|
7
|
-
dryad-core (= 0.2.
|
8
|
-
dryad-cluster (0.2.
|
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)
|
9
9
|
concurrent-ruby (~> 1.1, >= 1.1.5)
|
10
|
-
dryad-core (= 0.2.
|
11
|
-
dryad-consul (0.2.
|
10
|
+
dryad-core (= 0.2.3)
|
11
|
+
dryad-consul (0.2.3)
|
12
12
|
diplomat (~> 2.2, >= 2.2.4)
|
13
|
-
dryad-core (= 0.2.
|
14
|
-
dryad-core (0.2.
|
13
|
+
dryad-core (= 0.2.3)
|
14
|
+
dryad-core (0.2.3)
|
15
15
|
|
16
16
|
GEM
|
17
17
|
remote: https://rubygems.org/
|
data/dryad-cluster/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dryad-cluster (0.2.
|
4
|
+
dryad-cluster (0.2.3)
|
5
5
|
concurrent-ruby (~> 1.1, >= 1.1.5)
|
6
|
-
dryad-core (= 0.2.
|
6
|
+
dryad-core (= 0.2.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -14,10 +14,10 @@ GEM
|
|
14
14
|
diplomat (2.2.4)
|
15
15
|
deep_merge (~> 1.0, >= 1.0.1)
|
16
16
|
faraday (~> 0.9)
|
17
|
-
dryad-consul (0.2.
|
17
|
+
dryad-consul (0.2.3)
|
18
18
|
diplomat (~> 2.2, >= 2.2.4)
|
19
|
-
dryad-core (= 0.2.
|
20
|
-
dryad-core (0.2.
|
19
|
+
dryad-core (= 0.2.3)
|
20
|
+
dryad-core (0.2.3)
|
21
21
|
faraday (0.15.4)
|
22
22
|
multipart-post (>= 1.2, < 3)
|
23
23
|
multipart-post (2.1.1)
|
@@ -9,7 +9,6 @@ module Dryad
|
|
9
9
|
class NoServicesError < Error; end
|
10
10
|
|
11
11
|
class << self
|
12
|
-
REGISTRY = Object.const_get(Dryad.configuration.registry)
|
13
12
|
CLUSTERS = {}
|
14
13
|
|
15
14
|
def round_robin(schema, service_name)
|
@@ -29,7 +28,8 @@ module Dryad
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def sorted_instances(service_name, schema, groups)
|
32
|
-
|
31
|
+
registry = Object.const_get(Dryad.configuration.registry)
|
32
|
+
sis = registry.service_instances(service_name, schema, groups)
|
33
33
|
sis.sort {|a, b| "#{a.address}:#{a.port}" <=> "#{b.address}:#{b.port}"}
|
34
34
|
end
|
35
35
|
end
|
data/dryad-consul/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dryad-consul (0.2.
|
4
|
+
dryad-consul (0.2.3)
|
5
5
|
diplomat (~> 2.2, >= 2.2.4)
|
6
|
-
dryad-core (= 0.2.
|
6
|
+
dryad-core (= 0.2.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
diplomat (2.2.4)
|
14
14
|
deep_merge (~> 1.0, >= 1.0.1)
|
15
15
|
faraday (~> 0.9)
|
16
|
-
dryad-core (0.2.
|
16
|
+
dryad-core (0.2.3)
|
17
17
|
faraday (0.15.4)
|
18
18
|
multipart-post (>= 1.2, < 3)
|
19
19
|
multipart-post (2.1.1)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "rails"
|
2
|
+
|
3
|
+
module Dryad
|
4
|
+
module Consul
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
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]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
initializer "dryad_consul.update_active_record_connection" do
|
14
|
+
config.after_initialize do
|
15
|
+
db_path = "#{Dryad.configuration.namespace}/#{Dryad.configuration.group}/database.yml"
|
16
|
+
db_config = Dryad::Consul::ConfigProvider.load(db_path)
|
17
|
+
ActiveRecord::Base.configurations = YAML.load(ERB.new(db_config.payload).result)
|
18
|
+
ActiveRecord::Base.establish_connection(Rails.env.to_sym)
|
19
|
+
rescue Dryad::Core::ConfigurationNotFound => e
|
20
|
+
raise e
|
21
|
+
rescue e
|
22
|
+
puts e.message
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
ActiveSupport.run_load_hooks(:dryad_consul, Consul)
|
28
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "diplomat"
|
2
2
|
require "dryad"
|
3
|
+
require "dryad/consul/railtie" if defined?(Rails)
|
3
4
|
require "dryad/consul/version"
|
4
5
|
require "dryad/consul/service_client"
|
5
6
|
require "dryad/consul/service_registry"
|
@@ -10,10 +11,5 @@ require "dryad/consul/config_provider"
|
|
10
11
|
module Dryad
|
11
12
|
module Consul
|
12
13
|
class Error < StandardError; end
|
13
|
-
|
14
|
-
::Diplomat.configure do |config|
|
15
|
-
config.url = "http://#{Dryad.configuration.consul[:host]}:#{Dryad.configuration.consul[:port]}"
|
16
|
-
config.options = { headers: { "X-Consul-Token" => Dryad.configuration.consul[:token] } } if Dryad.configuration.consul[:token]
|
17
|
-
end
|
18
14
|
end
|
19
15
|
end
|
data/dryad-core/Gemfile.lock
CHANGED
data/dryad-core/lib/dryad.rb
CHANGED
@@ -1,46 +1 @@
|
|
1
|
-
require "dryad/configuration"
|
2
1
|
require "dryad/core"
|
3
|
-
require "yaml"
|
4
|
-
require "erb"
|
5
|
-
|
6
|
-
DRYAD_COFNIG_FILE = ENV["DRYAD_CONFIG_FILE"] || "config/dryad.yml"
|
7
|
-
|
8
|
-
module Dryad
|
9
|
-
class Error < StandardError; end
|
10
|
-
|
11
|
-
class << self
|
12
|
-
attr_accessor :configuration
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.configuration
|
16
|
-
@configuration ||= Configuration.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.configure
|
20
|
-
yield(configuration)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.configure_with_file
|
24
|
-
environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "default"
|
25
|
-
opts = YAML.load(ERB.new(File.read(DRYAD_COFNIG_FILE)).result)[environment] || Configuration::DEFAULT_OPTIONS
|
26
|
-
|
27
|
-
if opts.respond_to? :deep_symbolize_keys!
|
28
|
-
opts.deep_symbolize_keys!
|
29
|
-
else
|
30
|
-
symbolize_keys_deep!(opts)
|
31
|
-
end
|
32
|
-
|
33
|
-
@configuration = Configuration.new(opts)
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
def self.symbolize_keys_deep!(hash)
|
38
|
-
hash.keys.each do |k|
|
39
|
-
symkey = k.respond_to?(:to_sym) ? k.to_sym : k
|
40
|
-
hash[symkey] = hash.delete k
|
41
|
-
symbolize_keys_deep! hash[symkey] if hash[symkey].is_a? Hash
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
Dryad.configure_with_file if File.exist?(DRYAD_COFNIG_FILE)
|
@@ -1,10 +1,5 @@
|
|
1
|
-
ENV['DRYAD_CONFIG_FILE'] = File.expand_path("dummy/config/dryad.yml", __dir__)
|
2
|
-
|
3
1
|
require "bundler/setup"
|
4
|
-
require "yaml"
|
5
|
-
require "erb"
|
6
2
|
require "dryad"
|
7
|
-
require "dryad/core"
|
8
3
|
|
9
4
|
RSpec.configure do |config|
|
10
5
|
# Enable flags like --only-failures and --next-failure
|
data/dryad.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
end
|
20
20
|
spec.bindir = "exe"
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
22
23
|
|
23
24
|
spec.add_dependency "dryad-core", Dryad::VERSION
|
24
25
|
spec.add_dependency "dryad-consul", Dryad::VERSION
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rails"
|
2
|
+
|
3
|
+
module Dryad
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
initializer "dryad.set_configs" do
|
6
|
+
ActiveSupport.on_load(:dryad) do
|
7
|
+
environment = ENV["RAILS_ENV"] || "default"
|
8
|
+
config = Dryad.load_config[environment].deep_symbolize_keys
|
9
|
+
Dryad.configuration = Dryad::Configuration.new(config)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
ActiveSupport.run_load_hooks(:dryad, Core)
|
14
|
+
end
|
data/lib/dryad/version.rb
CHANGED
data/lib/dryad.rb
CHANGED
@@ -1 +1,40 @@
|
|
1
1
|
require "dryad/version"
|
2
|
+
require "dryad/configuration"
|
3
|
+
require "dryad/core"
|
4
|
+
require "dryad/railtie" if defined?(Rails)
|
5
|
+
require "dryad/consul"
|
6
|
+
require "dryad/cluster"
|
7
|
+
|
8
|
+
module Dryad
|
9
|
+
class << self
|
10
|
+
attr_accessor :configuration
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure
|
17
|
+
yield(configuration)
|
18
|
+
end
|
19
|
+
|
20
|
+
def load_config
|
21
|
+
config_file = Pathname.new(Rails.root.join("config/dryad.yml"))
|
22
|
+
|
23
|
+
config = if config_file && config_file.exist?
|
24
|
+
require "yaml"
|
25
|
+
require "erb"
|
26
|
+
YAML.load(ERB.new(config_file.read).result) || {}
|
27
|
+
else
|
28
|
+
raise "Could not load dryad configuration. No such file - #{config_file}"
|
29
|
+
end
|
30
|
+
|
31
|
+
config
|
32
|
+
rescue Psych::SyntaxError => e
|
33
|
+
raise "YAML syntax error occurred while parsing #{config_file}. " \
|
34
|
+
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
35
|
+
"Error: #{e.message}"
|
36
|
+
rescue => e
|
37
|
+
raise e, "Cannot load dryad configuration:\n#{e.message}", e.backtrace
|
38
|
+
end
|
39
|
+
end
|
40
|
+
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.
|
4
|
+
version: 0.2.3
|
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-
|
11
|
+
date: 2019-06-03 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.
|
19
|
+
version: 0.2.3
|
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.3
|
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.
|
33
|
+
version: 0.2.3
|
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.
|
40
|
+
version: 0.2.3
|
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.
|
47
|
+
version: 0.2.3
|
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.
|
54
|
+
version: 0.2.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- dryad-consul/lib/dryad/consul.rb
|
141
141
|
- dryad-consul/lib/dryad/consul/config_provider.rb
|
142
142
|
- dryad-consul/lib/dryad/consul/key_value_client.rb
|
143
|
+
- dryad-consul/lib/dryad/consul/railtie.rb
|
143
144
|
- dryad-consul/lib/dryad/consul/service.rb
|
144
145
|
- dryad-consul/lib/dryad/consul/service_client.rb
|
145
146
|
- dryad-consul/lib/dryad/consul/service_registry.rb
|
@@ -163,7 +164,6 @@ files:
|
|
163
164
|
- dryad-core/bin/setup
|
164
165
|
- dryad-core/dryad-core.gemspec
|
165
166
|
- dryad-core/lib/dryad.rb
|
166
|
-
- dryad-core/lib/dryad/configuration.rb
|
167
167
|
- dryad-core/lib/dryad/core.rb
|
168
168
|
- dryad-core/lib/dryad/core/config_desc.rb
|
169
169
|
- dryad-core/lib/dryad/core/config_provider.rb
|
@@ -180,11 +180,12 @@ files:
|
|
180
180
|
- dryad-core/spec/dryad/core/service_instance_spec.rb
|
181
181
|
- dryad-core/spec/dryad/core/service_spec.rb
|
182
182
|
- dryad-core/spec/dryad/core_spec.rb
|
183
|
-
- dryad-core/spec/dryad_spec.rb
|
184
183
|
- dryad-core/spec/dummy/config/dryad.yml
|
185
184
|
- dryad-core/spec/spec_helper.rb
|
186
185
|
- dryad.gemspec
|
187
186
|
- lib/dryad.rb
|
187
|
+
- lib/dryad/configuration.rb
|
188
|
+
- lib/dryad/railtie.rb
|
188
189
|
- lib/dryad/version.rb
|
189
190
|
homepage: https://github.com/jack0pan/dryad.rb
|
190
191
|
licenses:
|
@@ -205,7 +206,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
206
|
- !ruby/object:Gem::Version
|
206
207
|
version: '0'
|
207
208
|
requirements: []
|
208
|
-
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 2.7.9
|
209
211
|
signing_key:
|
210
212
|
specification_version: 4
|
211
213
|
summary: Config Management & Service Registration and Discovery
|
@@ -1,21 +0,0 @@
|
|
1
|
-
RSpec.describe Dryad do
|
2
|
-
it "has a valid version number" do
|
3
|
-
expect(Dryad::Core::VERSION).not_to be(nil)
|
4
|
-
end
|
5
|
-
|
6
|
-
it "can be configured with config file" do
|
7
|
-
environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "default"
|
8
|
-
default_consul_config = YAML.load(ERB.new(File.read(ENV['DRYAD_CONFIG_FILE'])).result)[environment]["consul"]
|
9
|
-
expect(Dryad.configuration.consul[:host]).to eq(default_consul_config["host"])
|
10
|
-
expect(Dryad.configuration.consul[:port]).to eq(default_consul_config["port"])
|
11
|
-
end
|
12
|
-
|
13
|
-
it "can be configured with block" do
|
14
|
-
consul_config = { host: "block.consul.example", port: 8500 }
|
15
|
-
Dryad.configure do |config|
|
16
|
-
config.consul = consul_config
|
17
|
-
end
|
18
|
-
|
19
|
-
expect(Dryad.configuration.consul).to eq(consul_config)
|
20
|
-
end
|
21
|
-
end
|
File without changes
|