protobuf-nats 0.3.1 → 0.3.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: 6d293e4b986f3f85b53bfa414a672e80b15c9ff3
4
- data.tar.gz: e910a6511d0539b811948193466fa0e9789297b7
3
+ metadata.gz: a55bbcf7a29b27d1d9cfd00b88579581f8ab581b
4
+ data.tar.gz: fa5b7bafb1e967ee34cb79b3afef6119accb5efb
5
5
  SHA512:
6
- metadata.gz: 27ef6bb9f6c23dce96a92848545eef7309f953c3e424e89086fc1e6cf1841fca5f11b9cfb518b53fb7f40051a780cdbe89ee262cd1bfe03c92ab922043befe9d
7
- data.tar.gz: 7316ec766c74fc63b2c5c3f09fd046bacb64a63333e5a36720476368ecd8dd58fcaf93a59eecb2ebc3f5aea2ab87c4ee42d514459228c8cf5f521696811f455d
6
+ metadata.gz: d0f35efe85018a2f3eede00b73b4c5c84e9d499a12f3e487655031a05522040ab029e599a0fe45d5cc311ceccdca501c21554d5c868cded997bfe7aed96f4e39
7
+ data.tar.gz: c1bc44baeff5152bb07ec1abc4dbfa73209a02d7648f98178c453320fa5d67579537b29e887df6652eca40a026b4058bdf9adc6f87181c9cfc6035c6a2aefe13
data/lib/protobuf/nats.rb CHANGED
@@ -42,6 +42,32 @@ module Protobuf
42
42
  # Eagerly load the yml config.
43
43
  config
44
44
 
45
+ # We will always log an error.
46
+ def self.error_callbacks
47
+ @error_callbacks ||= [lambda { |error| log_error(error) }]
48
+ end
49
+
50
+ # Eagerly load the yml config.
51
+ error_callbacks
52
+
53
+ def self.on_error(&block)
54
+ fail ::ArgumentError unless block.arity == 1
55
+ error_callbacks << block
56
+ nil
57
+ end
58
+
59
+ def self.notify_error_callbacks(error)
60
+ error_callbacks.each do |callback|
61
+ begin
62
+ callback.call(error)
63
+ rescue => callback_error
64
+ log_error(callback_error)
65
+ end
66
+ end
67
+
68
+ nil
69
+ end
70
+
45
71
  def self.subscription_key(service_klass, service_method)
46
72
  service_class_name = service_klass.name.underscore.gsub("/", ".")
47
73
  service_method_name = service_method.to_s.underscore
@@ -83,7 +109,7 @@ module Protobuf
83
109
  end
84
110
 
85
111
  @client_nats_connection.on_error do |error|
86
- log_error(error)
112
+ notify_error_callbacks(error)
87
113
  end
88
114
 
89
115
  true
@@ -44,7 +44,7 @@ module Protobuf
44
44
  # Publish response.
45
45
  nats.publish(reply_id, response_data)
46
46
  rescue => error
47
- ::Protobuf::Nats.log_error(error)
47
+ ::Protobuf::Nats.notify_error_callbacks(error)
48
48
  end
49
49
  end
50
50
 
@@ -84,7 +84,7 @@ module Protobuf
84
84
  end
85
85
 
86
86
  nats.on_error do |error|
87
- ::Protobuf::Nats.log_error(error)
87
+ ::Protobuf::Nats.notify_error_callbacks(error)
88
88
  end
89
89
 
90
90
  nats.on_close do
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module Nats
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.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.3.1
4
+ version: 0.3.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-26 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: protobuf