dryad-consul 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9530815af9ae6e37deea60fd5a6ccc07132b8deb0b43a617b88de8fdbf113149
4
- data.tar.gz: 0cf4b631294f4fe9f960bb99ddc6fe3cc4abd3d900e626d2c21961dff11f28fe
3
+ metadata.gz: 07cd3118ee21cb1ee9bef8243d9db20787630ad0d6675c724a275e6627b9725d
4
+ data.tar.gz: 8d94a70b7d56260a4c91d431e7ea5a6bc92af7f276b2c1e67d857d32063983f4
5
5
  SHA512:
6
- metadata.gz: f3d8656ba76b1813c1527e00ff2914d68fb492a0d63aa9020bbe4d7c4ea686d385aae176f889b3a80e70a7b2af06d01c6f07a10bb27b8d83819f7b1cb9f1e1db
7
- data.tar.gz: 96ba38abf933d6629ab8eb7d67dd3ff9c608af4286cf6b17e75dfe1064447b869aa480c239beb0acb6b8b2101ed8bd3f8fab1217c441e3255f6e8e9b18f9ce85
6
+ metadata.gz: a28e53773a1512ccf578ae3427318b9dd65d40a44a01bf827168f3232ead502318ae62f2aff91e0d4e6a404979d53b384f6be2dea176ef6dd0b7d4b07451a3dd
7
+ data.tar.gz: 2a0c0b87ea599010b00eac70a098dc722a250fa656ef2abc65c56ba3c7097e07076a6ee4a8093fd2b2e3643050e2fe2aee187c454f950f9bc631c291ecaf8e6a
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dryad-consul (0.2.1)
4
+ dryad-consul (0.2.3)
5
5
  diplomat (~> 2.2, >= 2.2.4)
6
- dryad-core (= 0.2.1)
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.1)
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,5 @@
1
1
  module Dryad
2
2
  module Consul
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.3'
4
4
  end
5
5
  end
data/lib/dryad/consul.rb CHANGED
@@ -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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dryad-consul
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
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-05-31 00:00:00.000000000 Z
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,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.1
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.1
26
+ version: 0.2.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: diplomat
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -106,6 +106,7 @@ files:
106
106
  - lib/dryad/consul.rb
107
107
  - lib/dryad/consul/config_provider.rb
108
108
  - lib/dryad/consul/key_value_client.rb
109
+ - lib/dryad/consul/railtie.rb
109
110
  - lib/dryad/consul/service.rb
110
111
  - lib/dryad/consul/service_client.rb
111
112
  - lib/dryad/consul/service_registry.rb
@@ -129,7 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
130
  - !ruby/object:Gem::Version
130
131
  version: '0'
131
132
  requirements: []
132
- rubygems_version: 3.0.3
133
+ rubyforge_project:
134
+ rubygems_version: 2.7.9
133
135
  signing_key:
134
136
  specification_version: 4
135
137
  summary: Dryad consul library.