fastly_nsq 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastly_nsq/message.rb +9 -2
- data/lib/fastly_nsq/version.rb +1 -1
- data/spec/message_spec.rb +13 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c2224ce762e2487411032220c774087ec93f288
|
4
|
+
data.tar.gz: c6b22724957b8d1cc9233f07c89a5b3ff0cd765e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 426790e527f752f503651e7c34f979eeecbe8908ae1adad34d9ce9d087c7b0d246859b7fa3b7067b22abdae2b4c3f47704f31c015d33b466492e5bca0e7ad16d
|
7
|
+
data.tar.gz: 6cff0c873d115bf3042f665f7c9ae6ba136f86ca5ec7dd305f1e32bf7e90ffff4e6adbded480ef4a13ba47e9e62ec9a1ae5c23e7011f6a8661131c4d81aa1849
|
data/lib/fastly_nsq/message.rb
CHANGED
@@ -34,10 +34,17 @@ class FastlyNsq::Message
|
|
34
34
|
nsq_message.finish
|
35
35
|
end
|
36
36
|
|
37
|
-
def requeue(
|
37
|
+
def requeue(timeout = nil)
|
38
38
|
return managed if managed
|
39
|
+
timeout ||= requeue_period
|
39
40
|
|
40
41
|
@managed = :requeued
|
41
|
-
nsq_message.requeue(
|
42
|
+
nsq_message.requeue(timeout)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def requeue_period
|
48
|
+
((attempts**4) + 45 + (rand(60) * (attempts + 1))) * 1_000
|
42
49
|
end
|
43
50
|
end
|
data/lib/fastly_nsq/version.rb
CHANGED
data/spec/message_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
require 'json'
|
5
5
|
|
6
6
|
RSpec.describe FastlyNsq::Message do
|
7
|
-
let(:nsq_message) { double 'Nsq::Message', body: json_body, attempts:
|
7
|
+
let(:nsq_message) { double 'Nsq::Message', body: json_body, attempts: 1, finish: nil, requeue: nil, touch: nil, timestamp: nil }
|
8
8
|
let(:body) { { 'data' => 'goes here', 'other_field' => 'is over here', 'meta' => 'meta stuff' } }
|
9
9
|
let(:json_body) { body.to_json }
|
10
10
|
subject { FastlyNsq::Message.new nsq_message }
|
@@ -57,4 +57,16 @@ RSpec.describe FastlyNsq::Message do
|
|
57
57
|
|
58
58
|
expect(subject.managed).to eq(:finished)
|
59
59
|
end
|
60
|
+
|
61
|
+
it 'uses the passed timeout for the requeue timeout' do
|
62
|
+
expect(nsq_message).to receive(:requeue).with(1000)
|
63
|
+
|
64
|
+
subject.requeue(1000)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'uses exponential backoff for timeout if none is given' do
|
68
|
+
expect(nsq_message).to receive(:requeue).with(46_000..166_000)
|
69
|
+
|
70
|
+
subject.requeue
|
71
|
+
end
|
60
72
|
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.
|
4
|
+
version: 1.4.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-04-
|
16
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: awesome_print
|
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
requirements: []
|
241
241
|
rubyforge_project:
|
242
|
-
rubygems_version: 2.
|
242
|
+
rubygems_version: 2.6.14
|
243
243
|
signing_key:
|
244
244
|
specification_version: 4
|
245
245
|
summary: Fastly NSQ Adapter
|