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 +4 -4
- data/lib/protobuf/nats.rb +27 -1
- data/lib/protobuf/nats/server.rb +2 -2
- 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: a55bbcf7a29b27d1d9cfd00b88579581f8ab581b
|
4
|
+
data.tar.gz: fa5b7bafb1e967ee34cb79b3afef6119accb5efb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
112
|
+
notify_error_callbacks(error)
|
87
113
|
end
|
88
114
|
|
89
115
|
true
|
data/lib/protobuf/nats/server.rb
CHANGED
@@ -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.
|
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.
|
87
|
+
::Protobuf::Nats.notify_error_callbacks(error)
|
88
88
|
end
|
89
89
|
|
90
90
|
nats.on_close do
|
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.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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: protobuf
|