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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b4f7a7217fe39c0e3aa4b20064c3afc20bcebff
4
- data.tar.gz: e6704320debc2d5241fb6a0306941a06ab44b45d
3
+ metadata.gz: 659e3bc2faf4807d8b288e45a22cd195f8a4b0b0
4
+ data.tar.gz: 6ac5c5e2c021175098a36de49f6aa3d9c3e45447
5
5
  SHA512:
6
- metadata.gz: f0d85a49668fea2402f44661d834b5b75284499801e245224c80c5ab528c2e9ef7771d2a5e5aadef88a5dab1c20e85e2d583fa6fecf3d3b8594bbc77a09068f7
7
- data.tar.gz: 16e27c6bf470214dac9c403af3849b942501edccb675a13cb606b4014da47053908d65a86aad5dca1aa516862ffd6d588cce1c9fd63cb590397015e2d2291087
6
+ metadata.gz: 98fbb73389beddcaa790e729f51b951e86b55c069c049f0d743e692076177628f2d4d1469fc6036632971a9c87767b795930a63f6daa614310fe4c2d5dfc3b88
7
+ data.tar.gz: 35ed5f00d4c675114934ffc20996ebc0c60ec6156943277f63be746f8c4d19536cb8f48fe4ed041690d3f79849a222394b51902a249bd1c738419eb0e1107ad5
@@ -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
- retries ||= 3
26
-
27
- setup_connection
28
- request_options = {:timeout => 60, :ack_timeout => 5}
29
- @response_data = nats_request_with_two_responses(cached_subscription_key, @request_data, request_options)
30
- parse_response
31
- rescue ::NATS::IO::Timeout
32
- # Nats response timeout.
33
- retry if (retries -= 1) > 0
34
- raise
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
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module Nats
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
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.1
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-13 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: protobuf