fastly_nsq 1.9.3 → 1.10.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
2
  SHA256:
3
- metadata.gz: 60a5dae5d0ca5d80aae1aff914ea705b6d3303c957ea4380de1d2038d82f9283
4
- data.tar.gz: ce70c136e7a4d192a077b5b8daf9a62bcb95ee8640e057dd796034b5386b774a
3
+ metadata.gz: 50a60efb4df61a42c1a86afc21062375622f93e3d68d8f0c6f08ff60e44aa57b
4
+ data.tar.gz: effddde6ad0930afb14c007f03aada0637437651ccd62b36c1b5a1b5b84a4344
5
5
  SHA512:
6
- metadata.gz: d7db6c545ae860e6faf892a6b8f172d02fae61b0c1257a61270bfe3acbb2e3d4c6c19f994b1fdf61db5ade5e38f90d9112afb381302b36b948ff693aa3a8ae0a
7
- data.tar.gz: a3046c80c90a7f989b3f34e403c383938de9f1c019bfde537354a5d47b8017604008e42311740d0a94bd841df01d6af4ecc184c09d6a0094af29142a9a5cfa7b
6
+ metadata.gz: d3a447b9a80c310994775ebd89d13bcdde8ccd4f9d9defa4891f9a67d62a2a4ac63c79a0dffaa93c906721e5e2e90504fdefc8ca7137740c23e1509ef64003ef
7
+ data.tar.gz: 2b602098ff5095cba6c8fc1f02ec9cdd693c4cc0ba7361fe43a1a63b5b641218016b086da426c3052ffd40758e2a6abf865733f7bcbd894f9f2dff1a14c01725
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.10.0](https://github.com/fastly/fastly_nsq/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.9.3...v1.10.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - add max\_req\_timeout \[IE-2040\] [\#85](https://github.com/fastly/fastly_nsq/pull/85) ([leklund](https://github.com/leklund))
10
+
3
11
  ## [v1.9.3](https://github.com/fastly/fastly_nsq/tree/v1.9.3) (2018-07-13)
4
12
  [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.9.2...v1.9.3)
5
13
 
@@ -373,4 +381,4 @@
373
381
  ## [v0.0.1](https://github.com/fastly/fastly_nsq/tree/v0.0.1) (2016-01-30)
374
382
 
375
383
 
376
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
384
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/README.md CHANGED
@@ -157,6 +157,9 @@ FastlyNsq.configure do |config|
157
157
  config.logger = Logger.new
158
158
  config.preprocessor = ->(_) { FastlyNsq.logger.info 'PREPROCESSESES' }
159
159
 
160
+ config.max_attempts = 20
161
+ config.max_req_timeout = (60 * 60 * 4 * 1_000) # 4 hours
162
+
160
163
  lc.listen 'posts', ->(m) { puts "posts: #{m.body}" }
161
164
  lc.listen 'blogs', ->(m) { puts "blogs: #{m.body}" }, priority: 3
162
165
  end
@@ -26,6 +26,10 @@ module FastlyNsq
26
26
  # @return [Integer]
27
27
  attr_accessor :max_attempts
28
28
 
29
+ # Set Maximum requeue timeout in milliseconds
30
+ # @return [Integer]
31
+ attr_writer :max_req_timeout
32
+
29
33
  # @return [Logger]
30
34
  attr_writer :logger
31
35
 
@@ -87,6 +91,17 @@ module FastlyNsq
87
91
  @manager = manager
88
92
  end
89
93
 
94
+ ##
95
+ # Maximum requeue timeout in milliseconds. This setting controls the
96
+ # maximum value that will be sent from FastlyNsq::Message#requeue This
97
+ # value should be less than or equal to the nsqd command line option
98
+ # +max-req-timeout+. The default setting is 1 hour.
99
+ # @return [Integer]
100
+ # @see https://nsq.io/components/nsqd.html#command-line-options
101
+ def max_req_timeout
102
+ @max_req_timeout ||= ENV.fetch('MAX_REQ_TIMEOUT', 60 * 60 * 1_000)
103
+ end
104
+
90
105
  ##
91
106
  # Return an array of NSQ lookupd http addresses sourced from ENV['NSQLOOKUPD_HTTP_ADDRESS']
92
107
  # @return [Array<String>] list of nsqlookupd http addresses
@@ -64,11 +64,16 @@ class FastlyNsq::Message
64
64
 
65
65
  ##
66
66
  # Requeue an NSQ Message
67
+ # If the +timeout+ parameter or the caclulated backoff is greater
68
+ # than FastlyNsq.max_req_timeout, the +max_req_timeout+ will be used
69
+ # to requeue the message.
67
70
  # @param timeout [Integer] timeout in milliseconds
68
71
  def requeue(timeout = nil)
69
72
  return managed if managed
70
73
  timeout ||= requeue_period
71
74
 
75
+ timeout = [timeout, FastlyNsq.max_req_timeout].min
76
+
72
77
  @managed = :requeued
73
78
  nsq_message.requeue(timeout)
74
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastlyNsq
4
- VERSION = '1.9.3'
4
+ VERSION = '1.10.0'
5
5
  end
@@ -69,4 +69,10 @@ RSpec.describe FastlyNsq::Message do
69
69
 
70
70
  subject.requeue
71
71
  end
72
+
73
+ it 'uses the FastlyNsq.max_req_timeout it timeout is larger than FastlyNsq.max_req_timeout' do
74
+ expect(nsq_message).to receive(:requeue).with(60 * 60 * 1_000)
75
+
76
+ subject.requeue(60 * 60 * 4 * 1_000)
77
+ end
72
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastly_nsq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.3
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy O'Neil
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2018-07-13 00:00:00.000000000 Z
16
+ date: 2018-07-23 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: awesome_print