protobuf-nats 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/protobuf/nats/client.rb +30 -10
- data/lib/protobuf/nats/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 659e3bc2faf4807d8b288e45a22cd195f8a4b0b0
|
4
|
+
data.tar.gz: 6ac5c5e2c021175098a36de49f6aa3d9c3e45447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98fbb73389beddcaa790e729f51b951e86b55c069c049f0d743e692076177628f2d4d1469fc6036632971a9c87767b795930a63f6daa614310fe4c2d5dfc3b88
|
7
|
+
data.tar.gz: 35ed5f00d4c675114934ffc20996ebc0c60ec6156943277f63be746f8c4d19536cb8f48fe4ed041690d3f79849a222394b51902a249bd1c738419eb0e1107ad5
|
data/lib/protobuf/nats/client.rb
CHANGED
@@ -21,17 +21,37 @@ module Protobuf
|
|
21
21
|
@subscription_key_cache ||= {}
|
22
22
|
end
|
23
23
|
|
24
|
+
# This is an alternative to depending on #failure for invoking the error callback.
|
25
|
+
# We never want to silence an error in the event that no callback is provided.
|
26
|
+
def failure_handler
|
27
|
+
yield
|
28
|
+
rescue => error
|
29
|
+
logger.debug { sign_message("Server failed request (invoking on_failure): #{error.inspect}") }
|
30
|
+
|
31
|
+
if @failure_cb
|
32
|
+
@failure_cb.call(error)
|
33
|
+
else
|
34
|
+
raise
|
35
|
+
end
|
36
|
+
ensure
|
37
|
+
complete
|
38
|
+
end
|
39
|
+
|
24
40
|
def send_request
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
41
|
+
failure_handler do
|
42
|
+
begin
|
43
|
+
retries ||= 3
|
44
|
+
|
45
|
+
setup_connection
|
46
|
+
request_options = {:timeout => 60, :ack_timeout => 5}
|
47
|
+
@response_data = nats_request_with_two_responses(cached_subscription_key, @request_data, request_options)
|
48
|
+
parse_response
|
49
|
+
rescue ::NATS::IO::Timeout
|
50
|
+
# Nats response timeout.
|
51
|
+
retry if (retries -= 1) > 0
|
52
|
+
raise
|
53
|
+
end
|
54
|
+
end
|
35
55
|
end
|
36
56
|
|
37
57
|
def cached_subscription_key
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf-nats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dewitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: protobuf
|