protobuf-nats 0.7.0 → 0.8.0
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 +8 -0
- data/lib/protobuf/nats/server.rb +16 -0
- data/lib/protobuf/nats/version.rb +1 -1
- data/protobuf-nats.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37d13406765b84608feb5c1b8edc2b694dd9b51e
|
4
|
+
data.tar.gz: 3a26cd0d3a925426a42448761abedfa7cd4e80e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 496a65ec0285610c3c44b913af26c6457e7cdd7fae9ec925d9826dfb523a090a41809256dd39f5822bdaafe5a3f412ab21d86c9cc1f0705a9b9ea2876b4e5940
|
7
|
+
data.tar.gz: d5f9f0460adfd3812c236257afa98256790be5bb30029dd2756eb6c9bc8020ec146ae9406db2e8f793b2b753be87048cbb001f01317a7902733ca0f30e5ed095
|
data/lib/protobuf/nats/client.rb
CHANGED
@@ -70,6 +70,12 @@ module Protobuf
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def send_request
|
73
|
+
::ActiveSupport::Notifications.instrument "client.request_duration.protobuf-nats" do
|
74
|
+
send_request_through_nats
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def send_request_through_nats
|
73
79
|
retries ||= 3
|
74
80
|
nack_retry ||= 0
|
75
81
|
|
@@ -79,9 +85,11 @@ module Protobuf
|
|
79
85
|
@response_data = nats_request_with_two_responses(cached_subscription_key, @request_data, request_options)
|
80
86
|
case @response_data
|
81
87
|
when :ack_timeout
|
88
|
+
::ActiveSupport::Notifications.instrument "client.request_timeout.protobuf-nats"
|
82
89
|
next if (retries -= 1) > 0
|
83
90
|
raise ::Protobuf::Nats::Errors::RequestTimeout
|
84
91
|
when :nack
|
92
|
+
::ActiveSupport::Notifications.instrument "client.request_nack.protobuf-nats"
|
85
93
|
interval = nack_backoff_intervals[nack_retry]
|
86
94
|
nack_retry += 1
|
87
95
|
raise ::Protobuf::Nats::Errors::RequestTimeout if interval.nil?
|
data/lib/protobuf/nats/server.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "active_support"
|
1
2
|
require "active_support/core_ext/class/subclasses"
|
2
3
|
require "protobuf/rpc/server"
|
3
4
|
require "protobuf/rpc/service"
|
@@ -43,14 +44,27 @@ module Protobuf
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def enqueue_request(request_data, reply_id)
|
47
|
+
::ActiveSupport::Notifications.instrument "server.message_received.protobuf-nats"
|
48
|
+
|
49
|
+
enqueued_at = ::Time.now
|
46
50
|
was_enqueued = thread_pool.push do
|
47
51
|
begin
|
52
|
+
# Instrument the thread pool time-to-execute duration.
|
53
|
+
processed_at = ::Time.now
|
54
|
+
::ActiveSupport::Notifications.instrument("server.thread_pool_execution_delay.protobuf-nats",
|
55
|
+
(processed_at - enqueued_at))
|
56
|
+
|
48
57
|
# Process request.
|
49
58
|
response_data = handle_request(request_data, 'server' => @server)
|
50
59
|
# Publish response.
|
51
60
|
nats.publish(reply_id, response_data)
|
52
61
|
rescue => error
|
53
62
|
::Protobuf::Nats.notify_error_callbacks(error)
|
63
|
+
ensure
|
64
|
+
# Instrument the request duration.
|
65
|
+
completed_at = ::Time.now
|
66
|
+
::ActiveSupport::Notifications.instrument("server.request_duration.protobuf-nats",
|
67
|
+
(completed_at - enqueued_at))
|
54
68
|
end
|
55
69
|
end
|
56
70
|
|
@@ -58,6 +72,8 @@ module Protobuf
|
|
58
72
|
if was_enqueued
|
59
73
|
nats.publish(reply_id, ::Protobuf::Nats::Messages::ACK)
|
60
74
|
else
|
75
|
+
::ActiveSupport::Notifications.instrument "server.message_dropped.protobuf-nats"
|
76
|
+
|
61
77
|
nats.publish(reply_id, ::Protobuf::Nats::Messages::NACK)
|
62
78
|
end
|
63
79
|
|
data/protobuf-nats.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
+
spec.add_runtime_dependency "activesupport", ">= 3.2"
|
33
34
|
spec.add_runtime_dependency "protobuf", "~> 3.7", ">= 3.7.2"
|
34
35
|
spec.add_runtime_dependency "nats-pure"
|
35
36
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf-nats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
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-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: protobuf
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
185
|
version: '0'
|
172
186
|
requirements: []
|
173
187
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.6.13
|
175
189
|
signing_key:
|
176
190
|
specification_version: 4
|
177
191
|
summary: ruby-protobuf client/server for nats
|