nsq-ruby 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 229c1d668e9a72a150cf31a0a961ceb167487ff9
4
- data.tar.gz: fd0037847e57c3d121c8cb3336b89552ab43c6e5
2
+ SHA256:
3
+ metadata.gz: 6c931ee31ebc9745dba9e2084740d6022f97b0ef280d1661cc1391910481eee9
4
+ data.tar.gz: '0965ea14b66ebfa6d1ca429af3cab05f970418f5cd41241362619b1e19444a08'
5
5
  SHA512:
6
- metadata.gz: 9bfde70b0deacc4ca79bad2dff9bf24494e7e713644ab3626f4ccea8b8e26e57863326e66d02d90fbe65c1ab1fa8f54387358a8bfdf30b17776a8f8528ba10d4
7
- data.tar.gz: c54f95f3fe6840d316f8fda50d4d4560def806ef58dc9f0d7b3fa85a846522ee3253da966b9b0fe2c104d2e52c3eb65566cdfef11b25a61646cee247b02d1066
6
+ metadata.gz: 67e99a8a1b6051325fd04e56bda7910eb41f46a39bf9baf9969bbfa8b04af5b9a6fc2297f707eb1ffdbb4a257a138112532639662a4e484ec47608ba93bdbcb9
7
+ data.tar.gz: bec66cc5f0990f97d55551b0b786ad0043c70d0dbe14e6b728726bbbdbd551caaac012adc5bf3d699113c3f11e9e9885ca579be41c9d7bcc205d7326f90d68ec
data/README.md CHANGED
@@ -191,6 +191,7 @@ producers when you're done with them.
191
191
  | `max_in_flight` | Max number of messages for this consumer to have in flight at a time | 1 |
192
192
  | `discovery_interval` | Seconds between queue discovery via nsqlookupd | 60.0 |
193
193
  | `msg_timeout` | Milliseconds before nsqd will timeout a message | 60000 |
194
+ | `max_attempts` | Number of times a message will be attempted before being finished | |
194
195
  | `tls_v1` | Flag for tls v1 connections | false |
195
196
  | `tls_options` | Optional keys and certificates for TLS connections | |
196
197
 
@@ -205,6 +206,7 @@ consumer = Nsq::Consumer.new(
205
206
  max_in_flight: 100,
206
207
  discovery_interval: 30,
207
208
  msg_timeout: 120_000,
209
+ max_attempts: 10,
208
210
  tls_v1: true,
209
211
  tls_options: {
210
212
  key: '/path/to/ssl/key.pem',
@@ -224,7 +226,8 @@ Notes:
224
226
  but to make the implementation of `nsq-ruby` as simple as possible, the minimum
225
227
  `max_in_flight` _per_ connection is 1. So if you set `max_in_flight` to 1 and
226
228
  are connected to 3 nsqds, you may have up to 3 messages in flight at a time.
227
-
229
+ - `max_attempts` is optional and if not set messages will be attempted until they
230
+ are explicitly finshed.
228
231
 
229
232
  ### `#pop`
230
233
 
@@ -32,6 +32,7 @@ module Nsq
32
32
  @msg_timeout = opts[:msg_timeout] || 60_000 # 60s
33
33
  @max_in_flight = opts[:max_in_flight] || 1
34
34
  @tls_options = opts[:tls_options]
35
+ @max_attempts = opts[:max_attempts]
35
36
  if opts[:ssl_context]
36
37
  if @tls_options
37
38
  warn 'ssl_context and tls_options both set. Using tls_options. Ignoring ssl_context.'
@@ -250,7 +251,11 @@ module Nsq
250
251
  error "Error received: #{frame.data}"
251
252
  elsif frame.is_a?(Message)
252
253
  debug "<<< #{frame.body}"
253
- @queue.push(frame) if @queue
254
+ if @max_attempts && frame.attempts > @max_attempts
255
+ fin(frame.id)
256
+ else
257
+ @queue.push(frame) if @queue
258
+ end
254
259
  else
255
260
  raise 'No data from socket'
256
261
  end
@@ -17,6 +17,7 @@ module Nsq
17
17
  @max_in_flight = opts[:max_in_flight] || 1
18
18
  @discovery_interval = opts[:discovery_interval] || 60
19
19
  @msg_timeout = opts[:msg_timeout]
20
+ @max_attempts = opts[:max_attempts]
20
21
  @ssl_context = opts[:ssl_context]
21
22
  @tls_options = opts[:tls_options]
22
23
  @tls_v1 = opts[:tls_v1]
@@ -75,7 +76,8 @@ module Nsq
75
76
  channel: @channel,
76
77
  queue: @messages,
77
78
  msg_timeout: @msg_timeout,
78
- max_in_flight: 1
79
+ max_in_flight: 1,
80
+ max_attempts: @max_attempts
79
81
  }.merge(options))
80
82
  end
81
83
 
@@ -1,7 +1,7 @@
1
1
  module Nsq
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 2
4
+ MINOR = 3
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nsq-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wistia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.6.8
112
+ rubygems_version: 2.7.6
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Ruby client library for NSQ