protobuf-nats 0.9.0 → 0.10.3

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
- SHA1:
3
- metadata.gz: 7c49c28f4b4cb3b40b36deb9f75b3bd3946cc5b0
4
- data.tar.gz: 95e4b3d9a014fef6f693b344f21d4deaef7ce9ad
2
+ SHA256:
3
+ metadata.gz: 167e2b896360bdf341fbdc1812de23e69cf28c2bf25057180fa68507176d8c55
4
+ data.tar.gz: 6ee287bffca6e3b5efeba47f76a43be764f38bee331a8d3164d3d1592dd132b4
5
5
  SHA512:
6
- metadata.gz: 3e0259df6a6b6612720a21764aaf61ea7462cb42ec424c2690892ff40ff532d6f8bcff7d838294728df50ec54255245b193dcf491358d8b290c13ebf5b4e5b69
7
- data.tar.gz: a75492a597508f386c4bc30714b20de27da114f4578e9f928e722e66d4f13c3f775294f684d7f3eb169445af2663775c82ffd4a9d65ec61537b9b52520d36f58
6
+ metadata.gz: 516f3f999e4c332fd3b211455d57514f2c01f13ef8d0cac8cd2d846c5139471d2c0f4cf63d839d3c3ecd3383b9782f0ac554c43923a8e611c8a1dd9b498419b2
7
+ data.tar.gz: f50854739d873a49f920f2cdabd229315722ebc42c833598b4f6a1cdcb5a6d4ca7040eb2a710487b7741270c28cb3314388492b488ab931677409d785bc6e7c5
@@ -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
- - gem install bundler -v 1.14.3
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.
@@ -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, subject) unless response
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, subject) unless response
296
+ fail(::Protobuf::Nats::Errors::ResponseTimeout, formatted_service_and_method_name) unless response
291
297
 
292
298
  response
293
299
  ensure
@@ -1,13 +1,13 @@
1
1
  module Protobuf
2
2
  module Nats
3
3
  module Errors
4
- class Base < ::StandardError
4
+ class ClientError < ::StandardError
5
5
  end
6
6
 
7
- class RequestTimeout < Base
7
+ class RequestTimeout < ClientError
8
8
  end
9
9
 
10
- class ResponseTimeout < Base
10
+ class ResponseTimeout < ClientError
11
11
  end
12
12
 
13
13
  class MriIOException < ::StandardError
@@ -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.pMsgs -= 1
194
- sub.pBytes -= message.getData.length if message.getData
195
- sub.delivered += 1 unless sub.isClosed
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
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module Nats
3
- VERSION = "0.9.0"
3
+ VERSION = "0.10.3"
4
4
  end
5
5
  end
@@ -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", "~> 1.14"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf-nats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.3
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: 2017-11-08 00:00:00.000000000 Z
11
+ date: 2020-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -62,30 +62,36 @@ dependencies:
62
62
  name: nats-pure
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0'
67
+ version: '0.3'
68
+ - - "<"
69
+ - !ruby/object:Gem::Version
70
+ version: '0.4'
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
82
  name: bundler
77
83
  requirement: !ruby/object:Gem::Requirement
78
84
  requirements:
79
- - - "~>"
85
+ - - ">="
80
86
  - !ruby/object:Gem::Version
81
- version: '1.14'
87
+ version: '0'
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: '1.14'
94
+ version: '0'
89
95
  - !ruby/object:Gem::Dependency
90
96
  name: rake
91
97
  requirement: !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
- homepage:
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: '0'
200
207
  requirements: []
201
- rubyforge_project:
202
- rubygems_version: 2.6.13
203
- signing_key:
208
+ rubygems_version: 3.1.2
209
+ signing_key:
204
210
  specification_version: 4
205
211
  summary: ruby-protobuf client/server for nats
206
212
  test_files: []