protobuf-nats 0.9.0.pre3 → 0.10.3.pre0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +9 -1
- data/README.md +2 -0
- data/ext/jars/jnats-1.1-SNAPSHOT.jar +0 -0
- data/lib/protobuf/nats.rb +1 -2
- data/lib/protobuf/nats/client.rb +10 -4
- data/lib/protobuf/nats/errors.rb +3 -3
- data/lib/protobuf/nats/jnats.rb +3 -8
- data/lib/protobuf/nats/server.rb +4 -2
- data/lib/protobuf/nats/version.rb +1 -1
- data/protobuf-nats.gemspec +2 -2
- data/scripts/install_gnatsd.sh +20 -0
- metadata +31 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3ff8c1cf794fd44ab13e6de90476890c29c083d242aa80a2f1e1072485c7bfe2
|
4
|
+
data.tar.gz: edba1e8c55228916e506e7840f4fae4b2118420b8ea1d2fc4879eac14169134c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2284a77ebd58b47b6812d221554d3becc19f4a724b648fc3d101fdfb8f9ebf73194b4cf92557cbfab458ffaa99e998f8fc37092fe5dc03ce16781ff7c3d0c4d
|
7
|
+
data.tar.gz: 1e9894389ae24f8ec6288b0022234277a00f49a6ad2f816137bdc80e4c3423b75e289f98db9560b2d926cfc6d7e4cc7fab10ccdbd0960fff12fa2c3f16c920ef
|
data/.travis.yml
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
+
jdk:
|
4
|
+
- openjdk8
|
3
5
|
rvm:
|
4
6
|
- 2.3.0
|
7
|
+
- 2.7.0
|
5
8
|
- jruby-9.1.7.0
|
9
|
+
- jruby-9.2.13.0
|
6
10
|
before_install:
|
7
|
-
|
11
|
+
# Install and start gnatsd
|
12
|
+
- ./scripts/install_gnatsd.sh
|
13
|
+
- $HOME/nats-server/nats-server &
|
14
|
+
# Install deps for project
|
15
|
+
- gem install bundler
|
8
16
|
- gem update --system
|
data/README.md
CHANGED
@@ -154,6 +154,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
154
154
|
|
155
155
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
156
156
|
|
157
|
+
The java-nats client is temporarily forked to support jruby > 9.2.10.0. The living branch for that is here: https://github.com/film42/java-nats/tree/jruby-compat. This will be removed when we upgrade to the new nats.java client.
|
158
|
+
|
157
159
|
## Contributing
|
158
160
|
|
159
161
|
Bug reports and pull requests are welcome on GitHub at https://github.com/abrandoned/protobuf-nats.
|
Binary file
|
data/lib/protobuf/nats.rb
CHANGED
@@ -78,11 +78,10 @@ module Protobuf
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.start_client_nats_connection
|
81
|
-
return true if @
|
81
|
+
return true if @client_nats_connection
|
82
82
|
|
83
83
|
GET_CONNECTED_MUTEX.synchronize do
|
84
84
|
break true if @client_nats_connection
|
85
|
-
break true if @start_client_nats_connection
|
86
85
|
|
87
86
|
# Disable publisher pending buffer on reconnect
|
88
87
|
options = config.connection_options.merge(:disable_reconnect_buffer => true)
|
data/lib/protobuf/nats/client.rb
CHANGED
@@ -151,12 +151,12 @@ module Protobuf
|
|
151
151
|
when :ack_timeout
|
152
152
|
::ActiveSupport::Notifications.instrument "client.request_timeout.protobuf-nats"
|
153
153
|
next if (retries -= 1) > 0
|
154
|
-
raise ::Protobuf::Nats::Errors::RequestTimeout
|
154
|
+
raise ::Protobuf::Nats::Errors::RequestTimeout, formatted_service_and_method_name
|
155
155
|
when :nack
|
156
156
|
::ActiveSupport::Notifications.instrument "client.request_nack.protobuf-nats"
|
157
157
|
interval = nack_backoff_intervals[nack_retry]
|
158
158
|
nack_retry += 1
|
159
|
-
raise ::Protobuf::Nats::Errors::RequestTimeout if interval.nil?
|
159
|
+
raise ::Protobuf::Nats::Errors::RequestTimeout, formatted_service_and_method_name if interval.nil?
|
160
160
|
sleep((interval + nack_backoff_splay)/1000.0)
|
161
161
|
next
|
162
162
|
end
|
@@ -186,6 +186,12 @@ module Protobuf
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
+
def formatted_service_and_method_name
|
190
|
+
klass = @options[:service]
|
191
|
+
method_name = @options[:method]
|
192
|
+
"#{klass}##{method_name}"
|
193
|
+
end
|
194
|
+
|
189
195
|
# The Java nats client offers better message queueing so we're going to use
|
190
196
|
# that over locking ourselves. This split in code isn't great, but we can
|
191
197
|
# refactor this later.
|
@@ -231,7 +237,7 @@ module Protobuf
|
|
231
237
|
else return :ack_timeout
|
232
238
|
end
|
233
239
|
|
234
|
-
fail(::Protobuf::Nats::Errors::ResponseTimeout,
|
240
|
+
fail(::Protobuf::Nats::Errors::ResponseTimeout, formatted_service_and_method_name) unless response
|
235
241
|
|
236
242
|
completed_request = true
|
237
243
|
response
|
@@ -287,7 +293,7 @@ module Protobuf
|
|
287
293
|
else return :ack_timeout
|
288
294
|
end
|
289
295
|
|
290
|
-
fail(::Protobuf::Nats::Errors::ResponseTimeout,
|
296
|
+
fail(::Protobuf::Nats::Errors::ResponseTimeout, formatted_service_and_method_name) unless response
|
291
297
|
|
292
298
|
response
|
293
299
|
ensure
|
data/lib/protobuf/nats/errors.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Protobuf
|
2
2
|
module Nats
|
3
3
|
module Errors
|
4
|
-
class
|
4
|
+
class ClientError < ::StandardError
|
5
5
|
end
|
6
6
|
|
7
|
-
class RequestTimeout <
|
7
|
+
class RequestTimeout < ClientError
|
8
8
|
end
|
9
9
|
|
10
|
-
class ResponseTimeout <
|
10
|
+
class ResponseTimeout < ClientError
|
11
11
|
end
|
12
12
|
|
13
13
|
class MriIOException < ::StandardError
|
data/lib/protobuf/nats/jnats.rb
CHANGED
@@ -5,11 +5,6 @@ require ::File.join(ext_base, "jars/slf4j-simple-1.7.25.jar")
|
|
5
5
|
require ::File.join(ext_base, "jars/gson-2.6.2.jar")
|
6
6
|
require ::File.join(ext_base, "jars/jnats-1.1-SNAPSHOT.jar")
|
7
7
|
|
8
|
-
# Set field accessors so we can access the member variables directly.
|
9
|
-
class Java::IoNatsClient::SubscriptionImpl
|
10
|
-
field_accessor :pMsgs, :pBytes, :delivered
|
11
|
-
end
|
12
|
-
|
13
8
|
module Protobuf
|
14
9
|
module Nats
|
15
10
|
class JNats
|
@@ -190,9 +185,9 @@ module Protobuf
|
|
190
185
|
# We have to update the subscription stats so we're not considered a slow consumer.
|
191
186
|
begin
|
192
187
|
sub.lock
|
193
|
-
sub.
|
194
|
-
sub.
|
195
|
-
sub.
|
188
|
+
sub.incrPMsgs(-1)
|
189
|
+
sub.incrPBytes(-message.getData.length) if message.getData
|
190
|
+
sub.incrDelivered(1) unless sub.isClosed
|
196
191
|
ensure
|
197
192
|
sub.unlock
|
198
193
|
end
|
data/lib/protobuf/nats/server.rb
CHANGED
@@ -12,6 +12,8 @@ module Protobuf
|
|
12
12
|
|
13
13
|
attr_reader :nats, :thread_pool, :subscriptions
|
14
14
|
|
15
|
+
MILLISECOND = 1000
|
16
|
+
|
15
17
|
def initialize(options)
|
16
18
|
@options = options
|
17
19
|
@processing_requests = true
|
@@ -52,7 +54,7 @@ module Protobuf
|
|
52
54
|
# Instrument the thread pool time-to-execute duration.
|
53
55
|
processed_at = ::Time.now
|
54
56
|
::ActiveSupport::Notifications.instrument("server.thread_pool_execution_delay.protobuf-nats",
|
55
|
-
(processed_at - enqueued_at))
|
57
|
+
(processed_at - enqueued_at) * MILLISECOND)
|
56
58
|
|
57
59
|
# Process request.
|
58
60
|
response_data = handle_request(request_data, 'server' => @server)
|
@@ -64,7 +66,7 @@ module Protobuf
|
|
64
66
|
# Instrument the request duration.
|
65
67
|
completed_at = ::Time.now
|
66
68
|
::ActiveSupport::Notifications.instrument("server.request_duration.protobuf-nats",
|
67
|
-
(completed_at - enqueued_at))
|
69
|
+
(completed_at - enqueued_at) * MILLISECOND)
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
data/protobuf-nats.gemspec
CHANGED
@@ -33,9 +33,9 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_runtime_dependency "activesupport", ">= 3.2"
|
34
34
|
spec.add_runtime_dependency "connection_pool"
|
35
35
|
spec.add_runtime_dependency "protobuf", "~> 3.7", ">= 3.7.2"
|
36
|
-
spec.add_runtime_dependency "nats-pure"
|
36
|
+
spec.add_runtime_dependency "nats-pure", "~> 0.3", "< 0.4"
|
37
37
|
|
38
|
-
spec.add_development_dependency "bundler"
|
38
|
+
spec.add_development_dependency "bundler"
|
39
39
|
spec.add_development_dependency "rake", "~> 10.0"
|
40
40
|
spec.add_development_dependency "rspec"
|
41
41
|
spec.add_development_dependency "benchmark-ips"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
export DEFAULT_NATS_SERVER_VERSION=v2.0.0
|
6
|
+
|
7
|
+
export NATS_SERVER_VERSION="${NATS_SERVER_VERSION:=$DEFAULT_NATS_SERVER_VERSION}"
|
8
|
+
|
9
|
+
# check to see if nats-server folder is empty
|
10
|
+
if [ ! "$(ls -A $HOME/nats-server)" ]; then
|
11
|
+
(
|
12
|
+
mkdir -p $HOME/nats-server
|
13
|
+
cd $HOME/nats-server
|
14
|
+
wget https://github.com/nats-io/nats-server/releases/download/$NATS_SERVER_VERSION/nats-server-$NATS_SERVER_VERSION-linux-amd64.zip -O nats-server.zip
|
15
|
+
unzip nats-server.zip
|
16
|
+
cp nats-server-$NATS_SERVER_VERSION-linux-amd64/nats-server $HOME/nats-server/nats-server
|
17
|
+
)
|
18
|
+
else
|
19
|
+
echo 'Using cached directory.';
|
20
|
+
fi
|
metadata
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf-nats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.3.pre0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dewitt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '3.2'
|
19
|
+
name: activesupport
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -25,12 +25,12 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: connection_pool
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
32
|
version: '0'
|
33
|
+
name: connection_pool
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,6 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: protobuf
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
@@ -48,6 +47,7 @@ dependencies:
|
|
48
47
|
- - ">="
|
49
48
|
- !ruby/object:Gem::Version
|
50
49
|
version: 3.7.2
|
50
|
+
name: protobuf
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -59,40 +59,46 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 3.7.2
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name: nats-pure
|
63
62
|
requirement: !ruby/object:Gem::Requirement
|
64
63
|
requirements:
|
65
|
-
- - "
|
64
|
+
- - "~>"
|
66
65
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
66
|
+
version: '0.3'
|
67
|
+
- - "<"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.4'
|
70
|
+
name: nats-pure
|
68
71
|
type: :runtime
|
69
72
|
prerelease: false
|
70
73
|
version_requirements: !ruby/object:Gem::Requirement
|
71
74
|
requirements:
|
72
|
-
- - "
|
75
|
+
- - "~>"
|
73
76
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
77
|
+
version: '0.3'
|
78
|
+
- - "<"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0.4'
|
75
81
|
- !ruby/object:Gem::Dependency
|
76
|
-
name: bundler
|
77
82
|
requirement: !ruby/object:Gem::Requirement
|
78
83
|
requirements:
|
79
|
-
- - "
|
84
|
+
- - ">="
|
80
85
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
86
|
+
version: '0'
|
87
|
+
name: bundler
|
82
88
|
type: :development
|
83
89
|
prerelease: false
|
84
90
|
version_requirements: !ruby/object:Gem::Requirement
|
85
91
|
requirements:
|
86
|
-
- - "
|
92
|
+
- - ">="
|
87
93
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
94
|
+
version: '0'
|
89
95
|
- !ruby/object:Gem::Dependency
|
90
|
-
name: rake
|
91
96
|
requirement: !ruby/object:Gem::Requirement
|
92
97
|
requirements:
|
93
98
|
- - "~>"
|
94
99
|
- !ruby/object:Gem::Version
|
95
100
|
version: '10.0'
|
101
|
+
name: rake
|
96
102
|
type: :development
|
97
103
|
prerelease: false
|
98
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -101,12 +107,12 @@ dependencies:
|
|
101
107
|
- !ruby/object:Gem::Version
|
102
108
|
version: '10.0'
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
|
-
name: rspec
|
105
110
|
requirement: !ruby/object:Gem::Requirement
|
106
111
|
requirements:
|
107
112
|
- - ">="
|
108
113
|
- !ruby/object:Gem::Version
|
109
114
|
version: '0'
|
115
|
+
name: rspec
|
110
116
|
type: :development
|
111
117
|
prerelease: false
|
112
118
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -115,12 +121,12 @@ dependencies:
|
|
115
121
|
- !ruby/object:Gem::Version
|
116
122
|
version: '0'
|
117
123
|
- !ruby/object:Gem::Dependency
|
118
|
-
name: benchmark-ips
|
119
124
|
requirement: !ruby/object:Gem::Requirement
|
120
125
|
requirements:
|
121
126
|
- - ">="
|
122
127
|
- !ruby/object:Gem::Version
|
123
128
|
version: '0'
|
129
|
+
name: benchmark-ips
|
124
130
|
type: :development
|
125
131
|
prerelease: false
|
126
132
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -129,12 +135,12 @@ dependencies:
|
|
129
135
|
- !ruby/object:Gem::Version
|
130
136
|
version: '0'
|
131
137
|
- !ruby/object:Gem::Dependency
|
132
|
-
name: pry
|
133
138
|
requirement: !ruby/object:Gem::Requirement
|
134
139
|
requirements:
|
135
140
|
- - ">="
|
136
141
|
- !ruby/object:Gem::Version
|
137
142
|
version: '0'
|
143
|
+
name: pry
|
138
144
|
type: :development
|
139
145
|
prerelease: false
|
140
146
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -178,12 +184,13 @@ files:
|
|
178
184
|
- lib/protobuf/nats/thread_pool.rb
|
179
185
|
- lib/protobuf/nats/version.rb
|
180
186
|
- protobuf-nats.gemspec
|
181
|
-
|
187
|
+
- scripts/install_gnatsd.sh
|
188
|
+
homepage:
|
182
189
|
licenses:
|
183
190
|
- MIT
|
184
191
|
metadata:
|
185
192
|
allowed_push_host: https://rubygems.org
|
186
|
-
post_install_message:
|
193
|
+
post_install_message:
|
187
194
|
rdoc_options: []
|
188
195
|
require_paths:
|
189
196
|
- lib
|
@@ -198,9 +205,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
205
|
- !ruby/object:Gem::Version
|
199
206
|
version: 1.3.1
|
200
207
|
requirements: []
|
201
|
-
|
202
|
-
|
203
|
-
signing_key:
|
208
|
+
rubygems_version: 3.0.6
|
209
|
+
signing_key:
|
204
210
|
specification_version: 4
|
205
211
|
summary: ruby-protobuf client/server for nats
|
206
212
|
test_files: []
|