dryad-consul 0.1.1 → 0.2.0

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: 2701d5efd60a687bd75565f917f7a35ef50b602189fb5e2d28ca4c7bee42c1d9
4
- data.tar.gz: b8d4746b122dd6f08571649cad7f1659322042f8a668cc3c1f0713754613756e
3
+ metadata.gz: 6b3d7df222cf9cdd2cb3401a03af97b7f5cc5195f84307a71c3570a305d3c93c
4
+ data.tar.gz: e953dfcdab5576ff3cf118be53cd1b041eeed557759c86a8bee1d300d7143de1
5
5
  SHA512:
6
- metadata.gz: 339174599854c19e0a5c309949dcc3c20b3edc7d4ba46e143b2a5f6d13981fac86d9d6c82fa1cecda1a249ba33f62ad7c5f3a17f813466992fe7c8b55ef17e93
7
- data.tar.gz: 355bb3667656cd5dad05072aa08b7da36801a3e574d8af4601b8f0b2dc0b49884b00c6a06415cc7f109786233f8d38a6c2c7dafa70c482e61f7ec8c30e8f31bd
6
+ metadata.gz: 47c719b64b1bffce5646a2708f0211e9de0d512d039956080af23338f6a692724ea79292ecd26da25b609af95d9221c752b0a67450c2da528a294d4de9a94bf9
7
+ data.tar.gz: 2a1de26f4e4070560ae93b318091e397cb9f1796fda92bd6cf834fd854406f176fdc5cd00142f59053fb0a1f6c816bfa5bb4e1863cb0d05b355f16bfb13043cb
data/lib/dryad/consul.rb CHANGED
@@ -4,6 +4,8 @@ require "dryad/consul/version"
4
4
  require "dryad/consul/service_client"
5
5
  require "dryad/consul/service_registry"
6
6
  require "dryad/consul/service"
7
+ require "dryad/consul/key_value_client"
8
+ require "dryad/consul/config_provider"
7
9
 
8
10
  module Dryad
9
11
  module Consul
@@ -0,0 +1,16 @@
1
+ module Dryad
2
+ module Consul
3
+ class ConfigProvider < Dryad::Core::ConfigProvider
4
+ class << self
5
+ def load(path, listener = nil)
6
+ config = Dryad::Consul::KeyValueClient.get(path)
7
+ if config.nil?
8
+ raise Dryad::Core::ConfigurationNotFound, path
9
+ else
10
+ Dryad::Core::ConfigDesc.new(path, config.Value, config.ModifyIndex)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ require "ostruct"
2
+
3
+ module Dryad
4
+ module Consul
5
+ class KeyValueClient
6
+ class << self
7
+
8
+ # Get a value by its key, potentially blocking for the first or next value
9
+ # @param key [String] the key
10
+ # @return [OpenStruct] The base64-decoded value associated with the key
11
+ def get(path)
12
+ OpenStruct.new ::Diplomat::Kv.get(path, decode_values: true).first
13
+ rescue Diplomat::KeyNotFound
14
+ nil
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,10 +1,5 @@
1
1
  module Dryad
2
2
  module Consul
3
- MAJOR = 0
4
- MINOR = 1
5
- TINY = 1
6
- PRE = nil
7
-
8
- VERSION = [MAJOR, MINOR, TINY, PRE].compact.join(".")
3
+ VERSION = '0.2.0'
9
4
  end
10
5
  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.1.1
4
+ version: 0.2.0
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-28 00:00:00.000000000 Z
11
+ date: 2019-05-29 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.1.1
19
+ version: 0.2.0
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.1.1
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: diplomat
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +104,8 @@ files:
104
104
  - bin/setup
105
105
  - dryad-consul.gemspec
106
106
  - lib/dryad/consul.rb
107
+ - lib/dryad/consul/config_provider.rb
108
+ - lib/dryad/consul/key_value_client.rb
107
109
  - lib/dryad/consul/service.rb
108
110
  - lib/dryad/consul/service_client.rb
109
111
  - lib/dryad/consul/service_registry.rb