dryad 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/dryad.gemspec +2 -0
- data/lib/dryad/version.rb +1 -1
- metadata +8 -81
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.travis.yml +0 -19
- data/dryad-cluster/.gitignore +0 -11
- data/dryad-cluster/.rspec +0 -3
- data/dryad-cluster/Gemfile +0 -4
- data/dryad-cluster/Gemfile.lock +0 -50
- data/dryad-cluster/LICENSE +0 -19
- data/dryad-cluster/README.md +0 -35
- data/dryad-cluster/Rakefile +0 -6
- data/dryad-cluster/bin/console +0 -14
- data/dryad-cluster/bin/setup +0 -8
- data/dryad-cluster/dryad-cluster.gemspec +0 -31
- data/dryad-cluster/lib/dryad/cluster.rb +0 -40
- data/dryad-cluster/lib/dryad/cluster/railtie.rb +0 -15
- data/dryad-cluster/lib/dryad/cluster/round_robin.rb +0 -22
- data/dryad-cluster/lib/dryad/cluster/version.rb +0 -5
- data/dryad-cluster/spec/dryad/cluster/round_robin_spec.rb +0 -21
- data/dryad-cluster/spec/dryad/cluster_spec.rb +0 -42
- data/dryad-cluster/spec/spec_helper.rb +0 -16
- data/dryad-consul/.gitignore +0 -11
- data/dryad-consul/.rspec +0 -3
- data/dryad-consul/Gemfile +0 -4
- data/dryad-consul/Gemfile.lock +0 -45
- data/dryad-consul/LICENSE +0 -19
- data/dryad-consul/README.md +0 -35
- data/dryad-consul/Rakefile +0 -6
- data/dryad-consul/bin/console +0 -14
- data/dryad-consul/bin/setup +0 -8
- data/dryad-consul/dryad-consul.gemspec +0 -30
- data/dryad-consul/lib/dryad/consul.rb +0 -23
- data/dryad-consul/lib/dryad/consul/config_provider.rb +0 -16
- data/dryad-consul/lib/dryad/consul/key_value_client.rb +0 -19
- data/dryad-consul/lib/dryad/consul/railtie.rb +0 -28
- data/dryad-consul/lib/dryad/consul/service.rb +0 -33
- data/dryad-consul/lib/dryad/consul/service_client.rb +0 -15
- data/dryad-consul/lib/dryad/consul/service_registry.rb +0 -46
- data/dryad-consul/lib/dryad/consul/version.rb +0 -5
- data/dryad-consul/spec/dryad/consul/config_provider_spec.rb +0 -18
- data/dryad-consul/spec/dryad/consul/key_value_client_spec.rb +0 -22
- data/dryad-consul/spec/dryad/consul/service_client_spec.rb +0 -6
- data/dryad-consul/spec/dryad/consul/service_registry_spec.rb +0 -33
- data/dryad-consul/spec/dryad/consul/service_spec.rb +0 -23
- data/dryad-consul/spec/dryad/consul_spec.rb +0 -11
- data/dryad-consul/spec/spec_helper.rb +0 -14
- data/dryad-core/.gitignore +0 -11
- data/dryad-core/.rspec +0 -3
- data/dryad-core/.travis.yml +0 -7
- data/dryad-core/Gemfile +0 -4
- data/dryad-core/Gemfile.lock +0 -35
- data/dryad-core/LICENSE +0 -19
- data/dryad-core/README.md +0 -35
- data/dryad-core/Rakefile +0 -6
- data/dryad-core/bin/console +0 -14
- data/dryad-core/bin/setup +0 -8
- data/dryad-core/dryad-core.gemspec +0 -27
- data/dryad-core/lib/dryad/core.rb +0 -15
- data/dryad-core/lib/dryad/core/config_desc.rb +0 -13
- data/dryad-core/lib/dryad/core/config_provider.rb +0 -9
- data/dryad-core/lib/dryad/core/load_balancing.rb +0 -8
- data/dryad-core/lib/dryad/core/portal.rb +0 -21
- data/dryad-core/lib/dryad/core/schema.rb +0 -9
- data/dryad-core/lib/dryad/core/service.rb +0 -39
- data/dryad-core/lib/dryad/core/service_instance.rb +0 -14
- data/dryad-core/lib/dryad/core/version.rb +0 -5
- data/dryad-core/spec/dryad/core/config_desc_spec.rb +0 -11
- data/dryad-core/spec/dryad/core/load_balancing_spec.rb +0 -6
- data/dryad-core/spec/dryad/core/portal_spec.rb +0 -13
- data/dryad-core/spec/dryad/core/schema_spec.rb +0 -7
- data/dryad-core/spec/dryad/core/service_instance_spec.rb +0 -7
- data/dryad-core/spec/dryad/core/service_spec.rb +0 -14
- data/dryad-core/spec/dryad/core_spec.rb +0 -14
- data/dryad-core/spec/spec_helper.rb +0 -14
@@ -1,33 +0,0 @@
|
|
1
|
-
module Dryad
|
2
|
-
module Consul
|
3
|
-
class Service < Dryad::Core::Service
|
4
|
-
def to_registers
|
5
|
-
portals.map do |portal|
|
6
|
-
{
|
7
|
-
ID: portal.id,
|
8
|
-
Name: Service.full_name(portal.schema, name),
|
9
|
-
Address: address,
|
10
|
-
Port: portal.port,
|
11
|
-
EnableTagOverride: true,
|
12
|
-
Tags: tags(portal)
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
def tags(portal)
|
19
|
-
tags = [
|
20
|
-
"type = \"#{type_name}\"",
|
21
|
-
"priority = \"#{priority}\"",
|
22
|
-
"group = \"#{group}\"",
|
23
|
-
"schema = \"#{portal.schema}\"",
|
24
|
-
"pattern = \"#{portal.pattern}\""
|
25
|
-
]
|
26
|
-
if portal.non_certifications.count > 0
|
27
|
-
tags << "non_certifications = \"#{portal.non_certifications.join(",")}\""
|
28
|
-
end
|
29
|
-
tags.concat(load_balancing.map{|lb| "load_balancing = \"#{lb}\"" })
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Dryad
|
2
|
-
module Consul
|
3
|
-
class ServiceClient
|
4
|
-
class << self
|
5
|
-
def method_missing(name, *args, &block)
|
6
|
-
Diplomat::Service.send(name, *args, &block) || super
|
7
|
-
end
|
8
|
-
|
9
|
-
def respond_to_missing?(meth_id, with_private = false)
|
10
|
-
access_method?(meth_id) || super
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Dryad
|
2
|
-
module Consul
|
3
|
-
class ServiceRegistry
|
4
|
-
class << self
|
5
|
-
def register(service)
|
6
|
-
service.to_registers.each do |register|
|
7
|
-
ServiceClient.register(register)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def deregister(service)
|
12
|
-
service.portals.each do |portal|
|
13
|
-
ServiceClient.deregister(portal.id)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def service_instances(name, schema, groups)
|
18
|
-
all_services = ::Diplomat::Health.service(Dryad::Core::Service.full_name(schema, name))
|
19
|
-
service_instances = []
|
20
|
-
all_services.each do |service|
|
21
|
-
service_hash = service.Service
|
22
|
-
if !service_hash["Meta"].nil? && service_hash["Meta"].has_key?("group") &&
|
23
|
-
groups.include?(service_hash["Meta"]["group"])
|
24
|
-
service_instances << service_hash
|
25
|
-
else
|
26
|
-
groups.each do |group|
|
27
|
-
if service_hash["Tags"].include?("group = \"#{group}\"")
|
28
|
-
service_instances << service_hash
|
29
|
-
break
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
service_instances.map do |service|
|
35
|
-
Dryad::Core::ServiceInstance.new(
|
36
|
-
name: name,
|
37
|
-
schema: schema,
|
38
|
-
address: service["Address"],
|
39
|
-
port: service["Port"]
|
40
|
-
)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,22 +0,0 @@
|
|
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
|
@@ -1,33 +0,0 @@
|
|
1
|
-
RSpec.describe Dryad::Consul::ServiceRegistry do
|
2
|
-
before do
|
3
|
-
@portal = Dryad::Core::Portal.new(
|
4
|
-
schema: Dryad::Core::Schema::HTTP,
|
5
|
-
port: 3000,
|
6
|
-
pattern: '/*',
|
7
|
-
non_certifications: ['/*']
|
8
|
-
)
|
9
|
-
@service = Dryad::Consul::Service.new(
|
10
|
-
name: 'rails',
|
11
|
-
address: '127.0.0.1',
|
12
|
-
group: 'staging',
|
13
|
-
portals: [@portal],
|
14
|
-
priority: 10,
|
15
|
-
load_balancing: [Dryad::Core::LoadBalancing::URL_HASH]
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "gets the instances for a service" do
|
20
|
-
Dryad::Consul::ServiceRegistry.register(@service)
|
21
|
-
registers = @service.to_registers
|
22
|
-
service_instances = Dryad::Consul::ServiceRegistry.service_instances(
|
23
|
-
@service.name,
|
24
|
-
Dryad::Core::Schema::HTTP,
|
25
|
-
[@service.group]
|
26
|
-
)
|
27
|
-
expect(service_instances.count).to eq(registers.count)
|
28
|
-
service_instances.zip(registers).each do |instance, register|
|
29
|
-
expect(instance.name).to eq(register[:Name])
|
30
|
-
end
|
31
|
-
Dryad::Consul::ServiceRegistry.deregister(@service)
|
32
|
-
end
|
33
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
RSpec.describe Dryad::Consul::Service do
|
2
|
-
before do
|
3
|
-
@portal = Dryad::Core::Portal.new(
|
4
|
-
schema: Dryad::Core::Schema::HTTP,
|
5
|
-
port: 3000,
|
6
|
-
pattern: '/*',
|
7
|
-
non_certifications: ['/*']
|
8
|
-
)
|
9
|
-
@service = Dryad::Consul::Service.new(
|
10
|
-
name: 'http-service',
|
11
|
-
address: '127.0.0.1',
|
12
|
-
group: 'staging',
|
13
|
-
portals: [@portal],
|
14
|
-
priority: 10,
|
15
|
-
load_balancing: [Dryad::Core::LoadBalancing::URL_HASH]
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "gets all registers" do
|
20
|
-
registers = @service.to_registers
|
21
|
-
expect(registers.count).to eq(@service.portals.count)
|
22
|
-
end
|
23
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
RSpec.describe Dryad::Consul do
|
2
|
-
it "has a version number" do
|
3
|
-
expect(Dryad::Consul::VERSION).not_to be(nil)
|
4
|
-
end
|
5
|
-
|
6
|
-
it "has configured dependencies" do
|
7
|
-
config = OpenStruct.new({ consul: { host: "127.0.0.1", port: 8500 } })
|
8
|
-
Dryad::Consul.configure_consul(config)
|
9
|
-
expect(::Diplomat.configuration.url).to eq("http://127.0.0.1:8500")
|
10
|
-
end
|
11
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
require "dryad/consul"
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
# Enable flags like --only-failures and --next-failure
|
6
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
-
|
8
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
-
config.disable_monkey_patching!
|
10
|
-
|
11
|
-
config.expect_with :rspec do |c|
|
12
|
-
c.syntax = :expect
|
13
|
-
end
|
14
|
-
end
|
data/dryad-core/.gitignore
DELETED
data/dryad-core/.rspec
DELETED
data/dryad-core/.travis.yml
DELETED
data/dryad-core/Gemfile
DELETED
data/dryad-core/Gemfile.lock
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
dryad-core (0.2.3)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.3)
|
10
|
-
rake (10.5.0)
|
11
|
-
rspec (3.8.0)
|
12
|
-
rspec-core (~> 3.8.0)
|
13
|
-
rspec-expectations (~> 3.8.0)
|
14
|
-
rspec-mocks (~> 3.8.0)
|
15
|
-
rspec-core (3.8.0)
|
16
|
-
rspec-support (~> 3.8.0)
|
17
|
-
rspec-expectations (3.8.3)
|
18
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.8.0)
|
20
|
-
rspec-mocks (3.8.0)
|
21
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.8.0)
|
23
|
-
rspec-support (3.8.0)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
bundler (~> 2.0)
|
30
|
-
dryad-core!
|
31
|
-
rake (~> 10.0)
|
32
|
-
rspec (~> 3.0)
|
33
|
-
|
34
|
-
BUNDLED WITH
|
35
|
-
2.0.1
|
data/dryad-core/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
data/dryad-core/README.md
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Dryad::Core
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dryad/core`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'dryad-core'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install dryad-core
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dryad-core.
|
data/dryad-core/Rakefile
DELETED
data/dryad-core/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "dryad/core"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/dryad-core/bin/setup
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "dryad/core/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "dryad-core"
|
8
|
-
spec.version = Dryad::Core::VERSION
|
9
|
-
spec.authors = ["Pan Jie"]
|
10
|
-
spec.email = ["panjie@growingio.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{Dryad core library.}
|
13
|
-
spec.description = %q{Dryad core includes the basic objects.}
|
14
|
-
spec.homepage = "https://github.com/jack0pan/dryad.rb"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
-
end
|
20
|
-
spec.bindir = "exe"
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "dryad/core/config_desc"
|
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
|
-
|
10
|
-
module Dryad
|
11
|
-
module Core
|
12
|
-
class Error < StandardError; end
|
13
|
-
class ConfigurationNotFound < Error; end
|
14
|
-
end
|
15
|
-
end
|