dryad-consul 0.3.0 → 0.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebfad19cea21ae94dd248931ed5a37afbdd59f60ec9a65902b33c77c3bd9ffad
4
- data.tar.gz: 42de2e60a31f501314c04adc676720f10eac9f23499efcaf4b0b59eaf6713d18
3
+ metadata.gz: 1149060926d6c254097b6f498d80f5243d7ecda0b1a160394375f32ae807b0d0
4
+ data.tar.gz: 0c5a0c58e1b2a03723dc58fb6c830c440e7103166af5c75f4831b186e7af5980
5
5
  SHA512:
6
- metadata.gz: 4ac0341de021e32e7e7cedd25412a0c108c02fb085ca20c9c05bc28cd43f5c68a034ca018e2927fc1dd64e44c0b6b673a27ac62adf2725199328cb07246e9054
7
- data.tar.gz: bb233a9b8c98588d0fa00fb9d17f1b103ab62e0a22b16ab346811eee1d6554174dbbf8bf1d57e2c2b8cb186f346d291cbdc378e78ab9728a6a27c5ee56d5788c
6
+ metadata.gz: 847aa97e79ddb1c3f213610148d290e10d02f0df43dfc4416ed099cf044acdfd0920443b44260273e99b569b13fea0c1fc332f4b7b8e62c7815606cae8b344ed
7
+ data.tar.gz: eb3062b04cb425d63b30ad25acf0e9a745155581a45faa1b8d98e1f5323ba2f289f51f4238c0f75322e749342e27c7bcdccebcb77dd4a0fafb2b66cb59b62843
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dryad-consul (0.3.0)
4
+ dryad-consul (0.3.2)
5
5
  concurrent-ruby (~> 1.1, >= 1.1.5)
6
6
  diplomat (~> 2.2, >= 2.2.4)
7
- dryad-core (= 0.3.0)
7
+ dryad-core (= 0.3.2)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -15,7 +15,7 @@ GEM
15
15
  diplomat (2.2.5)
16
16
  deep_merge (~> 1.0, >= 1.0.1)
17
17
  faraday (~> 0.9)
18
- dryad-core (0.3.0)
18
+ dryad-core (0.3.2)
19
19
  faraday (0.15.4)
20
20
  multipart-post (>= 1.2, < 3)
21
21
  multipart-post (2.1.1)
@@ -0,0 +1,42 @@
1
+ module Dryad
2
+ module Consul
3
+ class HealthCheck
4
+ attr_accessor :deregister_critial_service_after
5
+
6
+ def initialize(duration)
7
+ @deregister_critial_service_after = duration
8
+ end
9
+ end
10
+
11
+ class TTLHealthCheck < HealthCheck
12
+ attr_accessor :ttl
13
+
14
+ def initialize(ttl, deregister_critial_service_after)
15
+ super(deregister_critial_service_after)
16
+ @ttl = ttl
17
+ end
18
+ end
19
+
20
+ class HTTPHealthCheck < HealthCheck
21
+ attr_accessor :http, :interval, :timeout
22
+
23
+ def initialize(http, interval, timeout, deregister_critial_service_after)
24
+ super(deregister_critial_service_after)
25
+ @http = http
26
+ @interval = interval
27
+ @timeout = timeout
28
+ end
29
+ end
30
+
31
+ class GRPCHealthCheck < HealthCheck
32
+ attr_accessor :grpc, :interval, :grpc_use_tls
33
+
34
+ def initialize(grpc, interval, grpc_use_tls, deregister_critial_service_after)
35
+ super(deregister_critial_service_after)
36
+ @grpc = grpc
37
+ @interval = interval
38
+ @grpc_use_tls = grpc_use_tls
39
+ end
40
+ end
41
+ end
42
+ end
@@ -23,7 +23,7 @@ module Dryad
23
23
  observer = ::Dryad::Consul::DBConfigObserver.new
24
24
  begin
25
25
  db_config = Dryad::Consul::ConfigProvider.instance.load(db_path, observer)
26
- raise Dryad::Core::ConfigurationNotFound, db_path
26
+ raise Dryad::Core::ConfigurationNotFound, db_path if db_config.nil?
27
27
  ActiveRecord::Base.configurations = YAML.load(ERB.new(db_config.payload).result)
28
28
  ActiveRecord::Base.establish_connection(Rails.env.to_sym)
29
29
  rescue Dryad::Core::ConfigurationNotFound => e
@@ -9,7 +9,8 @@ module Dryad
9
9
  Address: address,
10
10
  Port: portal.port,
11
11
  EnableTagOverride: true,
12
- Tags: tags(portal)
12
+ Tags: tags(portal),
13
+ Checks: checks(portal)
13
14
  }
14
15
  end
15
16
  end
@@ -28,6 +29,14 @@ module Dryad
28
29
  end
29
30
  tags.concat(load_balancing.map{|lb| "load_balancing = \"#{lb}\"" })
30
31
  end
32
+
33
+ def checks(portal)
34
+ if portal.check.nil? || !portal.check.is_a?(Dryad::Consul::HealthCheck)
35
+ []
36
+ else
37
+ [portal.check.attributes]
38
+ end
39
+ end
31
40
  end
32
41
  end
33
42
  end
@@ -1,5 +1,5 @@
1
1
  module Dryad
2
2
  module Consul
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
  end
data/lib/dryad/consul.rb CHANGED
@@ -8,6 +8,8 @@ require "dryad/consul/service"
8
8
  require "dryad/consul/key_value_client"
9
9
  require "dryad/consul/config_provider"
10
10
 
11
+ require "erb"
12
+
11
13
  module Dryad
12
14
  module Consul
13
15
  class Error < StandardError; end
@@ -17,7 +19,7 @@ module Dryad
17
19
  if consul[:username].nil? || consul[:password].nil?
18
20
  url = "http://#{consul[:host]}:#{consul[:port]}"
19
21
  else
20
- url = "http://#{consul[:username]}:#{consul[:password]}@#{consul[:host]}:#{consul[:port]}"
22
+ url = "http://#{consul[:username]}:#{ERB::Util.url_encode(consul[:password])}@#{consul[:host]}:#{consul[:port]}"
21
23
  end
22
24
  ::Diplomat.configure do |config|
23
25
  config.url = url
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.3.0
4
+ version: 0.3.2
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-06-14 00:00:00.000000000 Z
11
+ date: 2019-06-17 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.3.0
19
+ version: 0.3.2
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.3.0
26
+ version: 0.3.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: diplomat
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -126,6 +126,7 @@ files:
126
126
  - lib/dryad/consul.rb
127
127
  - lib/dryad/consul/config_observer.rb
128
128
  - lib/dryad/consul/config_provider.rb
129
+ - lib/dryad/consul/health_check.rb
129
130
  - lib/dryad/consul/key_value_client.rb
130
131
  - lib/dryad/consul/railtie.rb
131
132
  - lib/dryad/consul/service.rb