consul-rb 0.0.8 → 0.0.9
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 +4 -4
- data/lib/consul/client/http.rb +13 -2
- data/lib/consul/client.rb +2 -2
- data/lib/consul/version.rb +1 -1
- metadata +2 -3
- data/lib/consul/kv.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7b13045741583002fe5d6c70b52c7f7fc27a790
|
4
|
+
data.tar.gz: db1009eb269cd1554925ec1da771d07852565be9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72b3e35739ee2c8e03e0ee0d4a2e4ee76dcd3f6f070ca2685d90dcb145a65807a0c7b97d67e19ee1c42352b00ac5540d458b3c1b3d24a7fb276eb41243fd83f7
|
7
|
+
data.tar.gz: b34278fc18874e73710b31394efa4c43989001faebbb37293242873b01a6eb63f0b56f410887688a3bea315e8f35ad0d65f606bc8e07e35904545ab59c32a490
|
data/lib/consul/client/http.rb
CHANGED
@@ -12,10 +12,11 @@ module Consul
|
|
12
12
|
InavlidArgument = Class.new(StandardError)
|
13
13
|
|
14
14
|
class HTTP
|
15
|
-
def initialize(host:, port:, logger:)
|
15
|
+
def initialize(host:, port:, logger:, :rpc_retries_timeout)
|
16
16
|
@host = host
|
17
17
|
@port = port
|
18
18
|
@logger = logger
|
19
|
+
@rpc_retries_timeout = rpc_retries_timeout
|
19
20
|
end
|
20
21
|
|
21
22
|
def get(request_uri, recurse: false, raw: false)
|
@@ -129,7 +130,10 @@ module Consul
|
|
129
130
|
JSON.parse("[#{response.body}]")[0]
|
130
131
|
end
|
131
132
|
|
132
|
-
def http_request(method, uri, data = nil, timeout = 60)
|
133
|
+
def http_request(method, uri, data = nil, timeout = 60, rpc_retries_timeout = nil)
|
134
|
+
start = Time.now
|
135
|
+
rpc_retries_timeout ||= @rpc_retries_timeout
|
136
|
+
|
133
137
|
method = {
|
134
138
|
get: Net::HTTP::Get,
|
135
139
|
put: Net::HTTP::Put,
|
@@ -153,6 +157,13 @@ module Consul
|
|
153
157
|
end
|
154
158
|
rescue Net::ReadTimeout
|
155
159
|
raise TimeoutException, "timeout on #{uri}"
|
160
|
+
rescue RpcErrorException
|
161
|
+
if Time.now - start > rpc_retries_timeout
|
162
|
+
raise RpcErrorException, "#{response.code} on #{uri} lasted for over #{rpc_retries_timeout} seconds"
|
163
|
+
else
|
164
|
+
sleep 1
|
165
|
+
retry
|
166
|
+
end
|
156
167
|
end
|
157
168
|
|
158
169
|
response
|
data/lib/consul/client.rb
CHANGED
@@ -8,8 +8,8 @@ module Consul
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class V1
|
11
|
-
def http(host: "localhost", port: 8500, logger: Logger.new("/dev/null"))
|
12
|
-
HTTP.new(host: host, port: port, logger: logger)
|
11
|
+
def http(host: "localhost", port: 8500, logger: Logger.new("/dev/null"), rpc_retries_timeout: 10)
|
12
|
+
HTTP.new(host: host, port: port, logger: logger, rpc_retries_timeout: rpc_retries_timeout)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/consul/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consul-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Piavlo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -35,7 +35,6 @@ files:
|
|
35
35
|
- consul-rb.gemspec
|
36
36
|
- lib/consul/client.rb
|
37
37
|
- lib/consul/client/http.rb
|
38
|
-
- lib/consul/kv.rb
|
39
38
|
- lib/consul/version.rb
|
40
39
|
homepage: https://github.com/SupersonicAds/consul-rb
|
41
40
|
licenses:
|