protobuf-nats 0.3.2 → 0.3.3
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/protobuf/nats/client.rb +22 -42
- 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: f814c4c1e02c6a9b768e1ab2e0ed963af5098215
|
4
|
+
data.tar.gz: a2a120ca37a85cfe6bab4d505e0f4d48ddfba77b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c307b1b2e4cf076047b612c0bdbec5baadecdc28c2dab623bf8932243a039702b105e137b7ba95e74b0934121f4b8f2d41a0a9c64306f7647eafe0c372031d19
|
7
|
+
data.tar.gz: ed0fc48cb9c2928eb7221602013bde0c3c9eb1297efa139450f5b1baebce5773e16ade799feefb00a6cc09518ade8c7973544c778f6ab33dbfcf985764ea95cd
|
data/lib/protobuf/nats/client.rb
CHANGED
@@ -21,25 +21,6 @@ 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
|
-
begin
|
32
|
-
if @failure_cb
|
33
|
-
@failure_cb.call(error)
|
34
|
-
else
|
35
|
-
raise
|
36
|
-
end
|
37
|
-
ensure
|
38
|
-
# Complete stats and log
|
39
|
-
complete
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
24
|
def ack_timeout
|
44
25
|
@ack_timeout ||= if ::ENV.key?("PB_NATS_CLIENT_ACK_TIMEOUT")
|
45
26
|
::ENV["PB_NATS_CLIENT_ACK_TIMEOUT"].to_i
|
@@ -65,29 +46,28 @@ module Protobuf
|
|
65
46
|
end
|
66
47
|
|
67
48
|
def send_request
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
49
|
+
retries ||= 3
|
50
|
+
|
51
|
+
setup_connection
|
52
|
+
request_options = {:timeout => response_timeout, :ack_timeout => ack_timeout}
|
53
|
+
@response_data = nats_request_with_two_responses(cached_subscription_key, @request_data, request_options)
|
54
|
+
parse_response
|
55
|
+
rescue ::Protobuf::Nats::Errors::IOException => error
|
56
|
+
::Protobuf::Nats.log_error(error)
|
57
|
+
|
58
|
+
delay = reconnect_delay
|
59
|
+
logger.warn "An IOException was raised. We are going to sleep for #{delay} seconds."
|
60
|
+
sleep delay
|
61
|
+
|
62
|
+
retry if (retries -= 1) > 0
|
63
|
+
raise
|
64
|
+
rescue ::NATS::IO::Timeout
|
65
|
+
# Nats response timeout.
|
66
|
+
retry if (retries -= 1) > 0
|
67
|
+
raise
|
68
|
+
ensure
|
69
|
+
# Complete stats and log
|
70
|
+
complete
|
91
71
|
end
|
92
72
|
|
93
73
|
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.3.
|
4
|
+
version: 0.3.3
|
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-
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: protobuf
|