dryad 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 +4 -4
- data/DRYAD_VERSION +1 -1
- data/dryad-cluster/lib/dryad/cluster/version.rb +1 -6
- data/dryad-consul/lib/dryad/consul/config_provider.rb +16 -0
- data/dryad-consul/lib/dryad/consul/key_value_client.rb +19 -0
- data/dryad-consul/lib/dryad/consul/version.rb +1 -6
- data/dryad-consul/lib/dryad/consul.rb +2 -0
- data/dryad-consul/spec/dryad/consul/config_provider_spec.rb +18 -0
- data/dryad-consul/spec/dryad/consul/key_value_client_spec.rb +22 -0
- data/dryad-core/lib/dryad/core/config_desc.rb +13 -0
- data/dryad-core/lib/dryad/core/config_provider.rb +9 -0
- data/dryad-core/lib/dryad/core/version.rb +1 -6
- data/dryad-core/lib/dryad/core.rb +3 -0
- data/dryad-core/spec/dryad/core/config_desc_spec.rb +11 -0
- metadata +15 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aa0959a2ba9d45a628ad86863e1a996b5acdf76ebb4f3b35dd26af8e5bfa166
|
4
|
+
data.tar.gz: 0ccfcff2f13a96b2fece1b464f5f46c0a72e6dec1bd2c16c4c9e815a2b71fbe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ece57d341bd12a3d76452e81aff1ad944a4d7a9a6ce83d0ca49e996bd28b1ac887e8e4ffdbbcb425382870644747946aae59d9a5c72469a714a8b89bcb98cb31
|
7
|
+
data.tar.gz: d8d33833813226d79c82bcc4772114fd1ec7cd19f85da4d647ae2d6b2f54f151c803ea1989564a296193701d018eb18d5f183c4640c6267534411d35c3f13746
|
data/DRYAD_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -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
|
@@ -0,0 +1,18 @@
|
|
1
|
+
RSpec.describe Dryad::Consul::ConfigProvider do
|
2
|
+
before do
|
3
|
+
@key = "path/of/key"
|
4
|
+
@value = "value of key"
|
5
|
+
::Diplomat::Kv.put(@key, @value)
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
::Diplomat::Kv.delete(@key)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "load configuration with path" do
|
13
|
+
cd = Dryad::Consul::ConfigProvider.load(@key)
|
14
|
+
expect(cd.path).to eq(@key)
|
15
|
+
expect(cd.payload).to eq(@value)
|
16
|
+
expect(cd.version).to be > 0
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
RSpec.describe Dryad::Consul::KeyValueClient do
|
2
|
+
before do
|
3
|
+
@key = "path/of/key"
|
4
|
+
@value = "value of key"
|
5
|
+
::Diplomat::Kv.put(@key, @value)
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
::Diplomat::Kv.delete(@key)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "gets value with index" do
|
13
|
+
response = Dryad::Consul::KeyValueClient.get(@key)
|
14
|
+
expect(response.Value).to eq(@value)
|
15
|
+
expect(response.ModifyIndex).to be >= response.CreateIndex
|
16
|
+
end
|
17
|
+
|
18
|
+
it "gets value the key which is not existed" do
|
19
|
+
response = Dryad::Consul::KeyValueClient.get('key')
|
20
|
+
expect(response).to be nil
|
21
|
+
end
|
22
|
+
end
|
@@ -4,9 +4,12 @@ require "dryad/core/service"
|
|
4
4
|
require "dryad/core/portal"
|
5
5
|
require "dryad/core/load_balancing"
|
6
6
|
require "dryad/core/schema"
|
7
|
+
require "dryad/core/config_desc"
|
8
|
+
require "dryad/core/config_provider"
|
7
9
|
|
8
10
|
module Dryad
|
9
11
|
module Core
|
10
12
|
class Error < StandardError; end
|
13
|
+
class ConfigurationNotFound < Error; end
|
11
14
|
end
|
12
15
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
RSpec.describe Dryad::Core::ConfigDesc do
|
2
|
+
it "can be created and accessed" do
|
3
|
+
path = 'path/to/key'
|
4
|
+
payload = 'payload for path'
|
5
|
+
version = 1
|
6
|
+
cd = Dryad::Core::ConfigDesc.new(path, payload, version)
|
7
|
+
expect(cd.path).to eq(path)
|
8
|
+
expect(cd.payload).to eq(payload)
|
9
|
+
expect(cd.version).to eq(version)
|
10
|
+
end
|
11
|
+
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.
|
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-
|
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,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
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.
|
26
|
+
version: 0.2.0
|
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.
|
33
|
+
version: 0.2.0
|
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.
|
40
|
+
version: 0.2.0
|
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.
|
47
|
+
version: 0.2.0
|
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.
|
54
|
+
version: 0.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,10 +139,14 @@ files:
|
|
139
139
|
- dryad-consul/bin/setup
|
140
140
|
- dryad-consul/dryad-consul.gemspec
|
141
141
|
- dryad-consul/lib/dryad/consul.rb
|
142
|
+
- dryad-consul/lib/dryad/consul/config_provider.rb
|
143
|
+
- dryad-consul/lib/dryad/consul/key_value_client.rb
|
142
144
|
- dryad-consul/lib/dryad/consul/service.rb
|
143
145
|
- dryad-consul/lib/dryad/consul/service_client.rb
|
144
146
|
- dryad-consul/lib/dryad/consul/service_registry.rb
|
145
147
|
- dryad-consul/lib/dryad/consul/version.rb
|
148
|
+
- dryad-consul/spec/dryad/consul/config_provider_spec.rb
|
149
|
+
- dryad-consul/spec/dryad/consul/key_value_client_spec.rb
|
146
150
|
- dryad-consul/spec/dryad/consul/service_client_spec.rb
|
147
151
|
- dryad-consul/spec/dryad/consul/service_registry_spec.rb
|
148
152
|
- dryad-consul/spec/dryad/consul/service_spec.rb
|
@@ -162,12 +166,15 @@ files:
|
|
162
166
|
- dryad-core/lib/dryad.rb
|
163
167
|
- dryad-core/lib/dryad/configuration.rb
|
164
168
|
- dryad-core/lib/dryad/core.rb
|
169
|
+
- dryad-core/lib/dryad/core/config_desc.rb
|
170
|
+
- dryad-core/lib/dryad/core/config_provider.rb
|
165
171
|
- dryad-core/lib/dryad/core/load_balancing.rb
|
166
172
|
- dryad-core/lib/dryad/core/portal.rb
|
167
173
|
- dryad-core/lib/dryad/core/schema.rb
|
168
174
|
- dryad-core/lib/dryad/core/service.rb
|
169
175
|
- dryad-core/lib/dryad/core/service_instance.rb
|
170
176
|
- dryad-core/lib/dryad/core/version.rb
|
177
|
+
- dryad-core/spec/dryad/core/config_desc_spec.rb
|
171
178
|
- dryad-core/spec/dryad/core/load_balancing_spec.rb
|
172
179
|
- dryad-core/spec/dryad/core/portal_spec.rb
|
173
180
|
- dryad-core/spec/dryad/core/schema_spec.rb
|