dryad 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +10 -10
  3. data/dryad.gemspec +2 -0
  4. data/lib/dryad/version.rb +1 -1
  5. metadata +8 -81
  6. data/.gitignore +0 -11
  7. data/.rspec +0 -3
  8. data/.travis.yml +0 -19
  9. data/dryad-cluster/.gitignore +0 -11
  10. data/dryad-cluster/.rspec +0 -3
  11. data/dryad-cluster/Gemfile +0 -4
  12. data/dryad-cluster/Gemfile.lock +0 -50
  13. data/dryad-cluster/LICENSE +0 -19
  14. data/dryad-cluster/README.md +0 -35
  15. data/dryad-cluster/Rakefile +0 -6
  16. data/dryad-cluster/bin/console +0 -14
  17. data/dryad-cluster/bin/setup +0 -8
  18. data/dryad-cluster/dryad-cluster.gemspec +0 -31
  19. data/dryad-cluster/lib/dryad/cluster.rb +0 -40
  20. data/dryad-cluster/lib/dryad/cluster/railtie.rb +0 -15
  21. data/dryad-cluster/lib/dryad/cluster/round_robin.rb +0 -22
  22. data/dryad-cluster/lib/dryad/cluster/version.rb +0 -5
  23. data/dryad-cluster/spec/dryad/cluster/round_robin_spec.rb +0 -21
  24. data/dryad-cluster/spec/dryad/cluster_spec.rb +0 -42
  25. data/dryad-cluster/spec/spec_helper.rb +0 -16
  26. data/dryad-consul/.gitignore +0 -11
  27. data/dryad-consul/.rspec +0 -3
  28. data/dryad-consul/Gemfile +0 -4
  29. data/dryad-consul/Gemfile.lock +0 -45
  30. data/dryad-consul/LICENSE +0 -19
  31. data/dryad-consul/README.md +0 -35
  32. data/dryad-consul/Rakefile +0 -6
  33. data/dryad-consul/bin/console +0 -14
  34. data/dryad-consul/bin/setup +0 -8
  35. data/dryad-consul/dryad-consul.gemspec +0 -30
  36. data/dryad-consul/lib/dryad/consul.rb +0 -23
  37. data/dryad-consul/lib/dryad/consul/config_provider.rb +0 -16
  38. data/dryad-consul/lib/dryad/consul/key_value_client.rb +0 -19
  39. data/dryad-consul/lib/dryad/consul/railtie.rb +0 -28
  40. data/dryad-consul/lib/dryad/consul/service.rb +0 -33
  41. data/dryad-consul/lib/dryad/consul/service_client.rb +0 -15
  42. data/dryad-consul/lib/dryad/consul/service_registry.rb +0 -46
  43. data/dryad-consul/lib/dryad/consul/version.rb +0 -5
  44. data/dryad-consul/spec/dryad/consul/config_provider_spec.rb +0 -18
  45. data/dryad-consul/spec/dryad/consul/key_value_client_spec.rb +0 -22
  46. data/dryad-consul/spec/dryad/consul/service_client_spec.rb +0 -6
  47. data/dryad-consul/spec/dryad/consul/service_registry_spec.rb +0 -33
  48. data/dryad-consul/spec/dryad/consul/service_spec.rb +0 -23
  49. data/dryad-consul/spec/dryad/consul_spec.rb +0 -11
  50. data/dryad-consul/spec/spec_helper.rb +0 -14
  51. data/dryad-core/.gitignore +0 -11
  52. data/dryad-core/.rspec +0 -3
  53. data/dryad-core/.travis.yml +0 -7
  54. data/dryad-core/Gemfile +0 -4
  55. data/dryad-core/Gemfile.lock +0 -35
  56. data/dryad-core/LICENSE +0 -19
  57. data/dryad-core/README.md +0 -35
  58. data/dryad-core/Rakefile +0 -6
  59. data/dryad-core/bin/console +0 -14
  60. data/dryad-core/bin/setup +0 -8
  61. data/dryad-core/dryad-core.gemspec +0 -27
  62. data/dryad-core/lib/dryad/core.rb +0 -15
  63. data/dryad-core/lib/dryad/core/config_desc.rb +0 -13
  64. data/dryad-core/lib/dryad/core/config_provider.rb +0 -9
  65. data/dryad-core/lib/dryad/core/load_balancing.rb +0 -8
  66. data/dryad-core/lib/dryad/core/portal.rb +0 -21
  67. data/dryad-core/lib/dryad/core/schema.rb +0 -9
  68. data/dryad-core/lib/dryad/core/service.rb +0 -39
  69. data/dryad-core/lib/dryad/core/service_instance.rb +0 -14
  70. data/dryad-core/lib/dryad/core/version.rb +0 -5
  71. data/dryad-core/spec/dryad/core/config_desc_spec.rb +0 -11
  72. data/dryad-core/spec/dryad/core/load_balancing_spec.rb +0 -6
  73. data/dryad-core/spec/dryad/core/portal_spec.rb +0 -13
  74. data/dryad-core/spec/dryad/core/schema_spec.rb +0 -7
  75. data/dryad-core/spec/dryad/core/service_instance_spec.rb +0 -7
  76. data/dryad-core/spec/dryad/core/service_spec.rb +0 -14
  77. data/dryad-core/spec/dryad/core_spec.rb +0 -14
  78. 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,5 +0,0 @@
1
- module Dryad
2
- module Consul
3
- VERSION = '0.2.5'
4
- end
5
- 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,6 +0,0 @@
1
- RSpec.describe Dryad::Consul::ServiceClient do
2
- it "can get all services" do
3
- services = Dryad::Consul::ServiceClient.get_all()
4
- expect(services.consul.count).to be(0)
5
- end
6
- 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
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.1
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in dryad-core.gemspec
4
- gemspec
@@ -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
@@ -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.
@@ -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.
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -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__)
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -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