fastly_nsq 1.17.0 → 1.17.1
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 +4 -4
- data/.git-blame-ignore-revs +6 -0
- data/.ruby-version +1 -1
- data/.travis.yml +4 -2
- data/ChangeLog.md +8 -1
- data/Gemfile +8 -8
- data/README.md +1 -1
- data/Rakefile +10 -11
- data/fastly_nsq.gemspec +26 -26
- data/lib/fastly_nsq/cli.rb +43 -50
- data/lib/fastly_nsq/consumer.rb +6 -6
- data/lib/fastly_nsq/feeder.rb +5 -7
- data/lib/fastly_nsq/http/nsqd.rb +28 -28
- data/lib/fastly_nsq/http/nsqlookupd.rb +11 -11
- data/lib/fastly_nsq/http.rb +4 -4
- data/lib/fastly_nsq/launcher.rb +16 -16
- data/lib/fastly_nsq/listener.rb +16 -16
- data/lib/fastly_nsq/manager.rb +13 -12
- data/lib/fastly_nsq/message.rb +4 -4
- data/lib/fastly_nsq/messenger.rb +7 -7
- data/lib/fastly_nsq/new_relic.rb +8 -8
- data/lib/fastly_nsq/priority_queue.rb +2 -2
- data/lib/fastly_nsq/priority_thread_pool.rb +3 -3
- data/lib/fastly_nsq/producer.rb +7 -7
- data/lib/fastly_nsq/safe_thread.rb +1 -1
- data/lib/fastly_nsq/testing.rb +4 -3
- data/lib/fastly_nsq/tls_options.rb +6 -6
- data/lib/fastly_nsq/version.rb +1 -1
- data/lib/fastly_nsq.rb +27 -29
- data/spec/cli_spec.rb +2 -2
- data/spec/consumer_spec.rb +12 -12
- data/spec/fastly_nsq_spec.rb +31 -31
- data/spec/feeder_spec.rb +4 -4
- data/spec/http/nsqd_spec.rb +23 -23
- data/spec/http/nsqlookupd_spec.rb +19 -19
- data/spec/http_spec.rb +22 -22
- data/spec/integration_spec.rb +10 -10
- data/spec/launcher_spec.rb +21 -21
- data/spec/listener_spec.rb +50 -50
- data/spec/manager_spec.rb +27 -27
- data/spec/matchers/delegate.rb +4 -4
- data/spec/message_spec.rb +19 -19
- data/spec/messenger_spec.rb +63 -64
- data/spec/new_relic.rb +27 -27
- data/spec/priority_thread_pool_spec.rb +2 -2
- data/spec/producer_spec.rb +30 -30
- data/spec/spec_helper.rb +12 -12
- data/spec/support/http.rb +2 -2
- data/spec/support/webmock.rb +1 -1
- data/spec/testing_spec.rb +12 -12
- data/spec/tls_options_spec.rb +47 -47
- metadata +7 -8
- data/.rubocop.yml +0 -68
data/spec/listener_spec.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
RSpec.describe FastlyNsq::Listener do
|
6
|
-
let!(:topic) {
|
7
|
-
let!(:channel) {
|
6
|
+
let!(:topic) { "fnsq" }
|
7
|
+
let!(:channel) { "fnsq" }
|
8
8
|
let!(:messages) { [] }
|
9
9
|
let(:processor) { ->(m) { messages << m.body } }
|
10
10
|
|
11
11
|
before { reset_topic(topic, channel: channel) }
|
12
12
|
before { expect { subject }.to eventually(be_connected).within(5) }
|
13
|
-
after
|
13
|
+
after { subject.terminate if subject.connected? }
|
14
14
|
|
15
15
|
subject { described_class.new(topic: topic, channel: channel, processor: processor) }
|
16
16
|
|
17
|
-
describe
|
18
|
-
describe
|
17
|
+
describe "#initialize" do
|
18
|
+
describe "with FastlyNsq.max_attempts set" do
|
19
19
|
let!(:default_max_attempts) { FastlyNsq.max_attempts }
|
20
20
|
before { FastlyNsq.max_attempts = 19 }
|
21
21
|
after { FastlyNsq.max_attempts = default_max_attempts }
|
22
22
|
|
23
|
-
it
|
23
|
+
it "defaults to FastlyNsq.max_attempts" do
|
24
24
|
listener = described_class.new(topic: topic, processor: processor, channel: channel)
|
25
25
|
expect(listener.max_attempts).to eq(FastlyNsq.max_attempts)
|
26
26
|
|
@@ -31,91 +31,91 @@ RSpec.describe FastlyNsq::Listener do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
34
|
+
describe "with FastlyNsq.channel set" do
|
35
35
|
let!(:default_channel) { FastlyNsq.channel }
|
36
|
-
before { FastlyNsq.channel =
|
36
|
+
before { FastlyNsq.channel = "fnsq" }
|
37
37
|
after { FastlyNsq.channel = default_channel }
|
38
38
|
|
39
|
-
it
|
39
|
+
it "defaults to FastlyNsq.channel" do
|
40
40
|
listener = described_class.new(topic: topic, processor: processor)
|
41
41
|
expect(listener.channel).to eq(FastlyNsq.channel)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe
|
45
|
+
describe "with FastlyNsq.preprocessor set" do
|
46
46
|
let!(:default_preprocessor) { FastlyNsq.preprocessor }
|
47
|
-
before { FastlyNsq.preprocessor =
|
47
|
+
before { FastlyNsq.preprocessor = "fnsq" }
|
48
48
|
after { FastlyNsq.preprocessor = default_preprocessor }
|
49
49
|
|
50
|
-
it
|
50
|
+
it "defaults to FastlyNsq.preprocessor" do
|
51
51
|
listener = described_class.new(topic: topic, processor: processor, channel: channel)
|
52
52
|
expect(listener.preprocessor).to eq(FastlyNsq.preprocessor)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
56
|
+
describe "with FastlyNsq.logger set" do
|
57
57
|
let!(:default_logger) { FastlyNsq.logger }
|
58
58
|
before { FastlyNsq.logger = Logger.new(nil) }
|
59
59
|
after { FastlyNsq.logger = default_logger }
|
60
60
|
|
61
|
-
it
|
61
|
+
it "defaults to FastlyNsq.logger" do
|
62
62
|
listener = described_class.new(topic: topic, processor: processor, channel: channel)
|
63
63
|
expect(listener.logger).to eq(FastlyNsq.logger)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
67
|
+
it "warns when creating a listener for the same topic" do
|
68
68
|
expect(FastlyNsq.manager.logger).to receive(:warn).and_yield.and_return(match("#{topic} was added more than once"))
|
69
69
|
|
70
70
|
described_class.new(topic: topic, channel: channel, processor: processor)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
describe
|
74
|
+
describe "#priority" do
|
75
75
|
specify { expect(subject.priority).to eq(described_class::DEFAULT_PRIORITY) }
|
76
76
|
end
|
77
77
|
|
78
|
-
describe
|
78
|
+
describe "#consumer" do
|
79
79
|
specify { expect(subject.consumer).to be_a(FastlyNsq::Consumer) }
|
80
80
|
end
|
81
81
|
|
82
|
-
describe
|
82
|
+
describe "connect_timeout" do
|
83
83
|
specify { expect(subject.consumer.connect_timeout).to eq(described_class::DEFAULT_CONNECTION_TIMEOUT) }
|
84
84
|
end
|
85
85
|
|
86
|
-
it
|
87
|
-
expect { described_class.new(topic: topic, channel: channel, processor:
|
88
|
-
to raise_error(ArgumentError, match(
|
86
|
+
it "requires processor to respond_to #call" do
|
87
|
+
expect { described_class.new(topic: topic, channel: channel, processor: "foo") }
|
88
|
+
.to raise_error(ArgumentError, match("#call"))
|
89
89
|
end
|
90
90
|
|
91
|
-
it
|
92
|
-
expect { described_class.new(topic: topic, channel: channel, processor: ->(*) {}, priority:
|
93
|
-
to raise_error(ArgumentError, match(
|
91
|
+
it "requires priority to be a Fixnum" do
|
92
|
+
expect { described_class.new(topic: topic, channel: channel, processor: ->(*) {}, priority: "foo") }
|
93
|
+
.to raise_error(ArgumentError, match("Integer"))
|
94
94
|
end
|
95
95
|
|
96
|
-
describe
|
97
|
-
it
|
98
|
-
body = {
|
99
|
-
message = spy(
|
96
|
+
describe "#call" do
|
97
|
+
it "processes a message" do
|
98
|
+
body = {"foo" => "bar"}
|
99
|
+
message = spy("message", body: JSON.dump(body))
|
100
100
|
expect { subject.call(message) }.to change { messages }.to([body])
|
101
101
|
end
|
102
102
|
|
103
|
-
describe
|
103
|
+
describe "when the processor returns true" do
|
104
104
|
let(:processor) { ->(_) { true } }
|
105
105
|
|
106
|
-
it
|
107
|
-
message = spy(
|
106
|
+
it "finishes the message" do
|
107
|
+
message = spy("message", body: "{}")
|
108
108
|
subject.call(message)
|
109
109
|
|
110
110
|
expect(message).to have_received(:finish)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
describe
|
114
|
+
describe "when the processor returns false" do
|
115
115
|
let(:processor) { ->(_) { false } }
|
116
116
|
|
117
|
-
it
|
118
|
-
message = spy(
|
117
|
+
it "finishes the message" do
|
118
|
+
message = spy("message", body: "{}")
|
119
119
|
subject.call(message)
|
120
120
|
|
121
121
|
expect(message).not_to have_received(:finish)
|
@@ -125,18 +125,18 @@ RSpec.describe FastlyNsq::Listener do
|
|
125
125
|
|
126
126
|
it { should be_connected }
|
127
127
|
|
128
|
-
it
|
128
|
+
it "should terminate" do
|
129
129
|
expect { subject.terminate }.to change(subject, :connected?).to(false)
|
130
130
|
end
|
131
131
|
|
132
|
-
describe
|
133
|
-
let!(:message) { JSON.dump(
|
132
|
+
describe "faking", :fake do
|
133
|
+
let!(:message) { JSON.dump("foo" => "bar") }
|
134
134
|
|
135
135
|
before { subject }
|
136
136
|
|
137
137
|
it { should be_connected }
|
138
138
|
|
139
|
-
it
|
139
|
+
it "should terminate" do
|
140
140
|
expect { subject.terminate }.to change(subject, :connected?).to(false)
|
141
141
|
end
|
142
142
|
|
@@ -149,49 +149,49 @@ RSpec.describe FastlyNsq::Listener do
|
|
149
149
|
expect(test_message.raw_body).to eq(message)
|
150
150
|
end
|
151
151
|
|
152
|
-
describe
|
152
|
+
describe "when the processor returns true" do
|
153
153
|
let(:processor) { ->(_) { true } }
|
154
154
|
|
155
|
-
it
|
155
|
+
it "drains queued messages" do
|
156
156
|
FastlyNsq::Producer.new(topic: topic).write(message)
|
157
157
|
expect { subject.drain }.to change { subject.messages.size }.by(-1)
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
describe
|
161
|
+
describe "when the processor returns false" do
|
162
162
|
let(:processor) { ->(_) { false } }
|
163
163
|
|
164
|
-
it
|
164
|
+
it "does not remove messages" do
|
165
165
|
FastlyNsq::Producer.new(topic: topic).write(message)
|
166
166
|
expect { subject.drain }.not_to change { subject.messages.size }
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
describe
|
172
|
-
let!(:message) { JSON.dump(
|
171
|
+
describe "inline", :inline do
|
172
|
+
let!(:message) { JSON.dump("foo" => "bar") }
|
173
173
|
let!(:processor) { ->(m) { messages << m.raw_body } }
|
174
174
|
|
175
175
|
before { subject }
|
176
176
|
|
177
177
|
it { should be_connected }
|
178
178
|
|
179
|
-
it
|
179
|
+
it "should terminate" do
|
180
180
|
expect { subject.terminate }.to change(subject, :connected?).to(false)
|
181
181
|
end
|
182
182
|
|
183
|
-
describe
|
184
|
-
it
|
183
|
+
describe "when the processor returns true" do
|
184
|
+
it "processes and removes messages" do
|
185
185
|
expect { FastlyNsq::Producer.new(topic: topic).write(message) }.to change { messages.size }.by(1)
|
186
186
|
expect(messages).to contain_exactly(message)
|
187
187
|
expect(subject.messages).to be_empty
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
describe
|
191
|
+
describe "when the processor returns false" do
|
192
192
|
let(:processor) { ->(_) { false } }
|
193
193
|
|
194
|
-
it
|
194
|
+
it "does not remove messages" do
|
195
195
|
FastlyNsq::Producer.new(topic: topic).write(message)
|
196
196
|
expect { subject.drain }.not_to change { subject.messages.size }
|
197
197
|
end
|
data/spec/manager_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
RSpec.describe FastlyNsq::Manager do
|
6
|
-
let!(:topic) {
|
7
|
-
let!(:channel) {
|
6
|
+
let!(:topic) { "fnsq" }
|
7
|
+
let!(:channel) { "fnsq" }
|
8
8
|
|
9
9
|
subject { FastlyNsq.manager }
|
10
10
|
|
@@ -14,33 +14,33 @@ RSpec.describe FastlyNsq::Manager do
|
|
14
14
|
|
15
15
|
it { should_not be_stopped }
|
16
16
|
|
17
|
-
describe
|
18
|
-
it
|
17
|
+
describe "#initialize" do
|
18
|
+
it "allows max_threads to be specified" do
|
19
19
|
max_threads = FastlyNsq.max_processing_pool_threads * 2
|
20
20
|
manager = described_class.new(max_threads: max_threads)
|
21
21
|
|
22
22
|
expect(manager.pool.max_threads).to eq(max_threads)
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "defaults max_threads to FastlyNsq.max_processing_pool_threads" do
|
26
26
|
expect(subject.pool.max_threads).to eq(FastlyNsq.max_processing_pool_threads)
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it "allows fallback_policy to be specified" do
|
30
30
|
manager = described_class.new(fallback_policy: :abort)
|
31
31
|
|
32
32
|
expect(manager.pool.fallback_policy).to eq(:abort)
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it "defaults fallback_policy to caller_runs" do
|
36
36
|
expect(subject.pool.fallback_policy).to eq(:caller_runs)
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it "defaults logger to FastlyNsq.logger" do
|
40
40
|
expect(subject.logger).to eq(FastlyNsq.logger)
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
43
|
+
it "allows logger to be specified" do
|
44
44
|
logger = Logger.new(nil)
|
45
45
|
manager = described_class.new(logger: logger)
|
46
46
|
|
@@ -48,39 +48,39 @@ RSpec.describe FastlyNsq::Manager do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
context
|
51
|
+
context "with a listener" do
|
52
52
|
let!(:listener) { FastlyNsq::Listener.new(topic: topic, channel: channel, processor: ->(*) {}) }
|
53
53
|
before { expect { listener }.to eventually(be_connected).within(5) }
|
54
54
|
|
55
|
-
it
|
55
|
+
it "tracks listener" do
|
56
56
|
expect(subject.listeners).to contain_exactly(listener)
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it "tracks topic listeners" do
|
60
60
|
expect(subject.topic_listeners).to eq(topic => listener)
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
63
|
+
it "tracks topics" do
|
64
64
|
expect(subject.topics).to contain_exactly(topic)
|
65
65
|
end
|
66
66
|
|
67
|
-
describe
|
68
|
-
it
|
67
|
+
describe "#terminate" do
|
68
|
+
it "terminates listeners" do
|
69
69
|
expect { subject.terminate(2) }.to change(listener, :connected?).to(false)
|
70
70
|
end
|
71
71
|
|
72
|
-
it
|
72
|
+
it "terminates the processing pool" do
|
73
73
|
expect { subject.terminate(2) }.to change(subject.pool, :shutdown?).to(true)
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
77
|
-
expect { subject.terminate(2) }
|
76
|
+
it "stops" do
|
77
|
+
expect { subject.terminate(2) }.to change(subject, :stopped?).from(false).to(true)
|
78
78
|
end
|
79
79
|
|
80
|
-
context
|
80
|
+
context "when the pool does not terminate within a the specified timeframe" do
|
81
81
|
before { expect(subject.pool).to receive(:shutdown).and_return(false) }
|
82
82
|
|
83
|
-
it
|
83
|
+
it "kills the pool" do
|
84
84
|
expect(subject.pool).to receive(:kill).once.and_call_original
|
85
85
|
|
86
86
|
expect { subject.terminate(0.1) }.to change(subject.pool, :shutdown?).to(true)
|
@@ -89,19 +89,19 @@ RSpec.describe FastlyNsq::Manager do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
92
|
+
it "transfers" do
|
93
93
|
manager = described_class.new
|
94
94
|
|
95
95
|
listener = nil
|
96
96
|
# register listener with default manager
|
97
|
-
expect { listener = FastlyNsq::Listener.new(topic: topic, channel: channel, processor: ->(*) {}) }
|
98
|
-
to change { FastlyNsq.manager.listeners.size }.by(1)
|
97
|
+
expect { listener = FastlyNsq::Listener.new(topic: topic, channel: channel, processor: ->(*) {}) }
|
98
|
+
.to change { FastlyNsq.manager.listeners.size }.by(1)
|
99
99
|
expect { listener }.to eventually(be_connected).within(5)
|
100
100
|
|
101
101
|
# transfer listener to new manager
|
102
|
-
expect { FastlyNsq.manager.transfer(manager) }
|
103
|
-
to change { manager.listeners.size }.by(1)
|
104
|
-
and change { FastlyNsq.manager.listeners.size }.by(-1)
|
102
|
+
expect { FastlyNsq.manager.transfer(manager) }
|
103
|
+
.to change { manager.listeners.size }.by(1)
|
104
|
+
.and change { FastlyNsq.manager.listeners.size }.by(-1)
|
105
105
|
|
106
106
|
# old manager processing is disabled
|
107
107
|
expect(FastlyNsq.manager.pool).to be_shutdown
|
data/spec/matchers/delegate.rb
CHANGED
@@ -9,22 +9,22 @@ RSpec::Matchers.define :delegate do |method|
|
|
9
9
|
rescue NoMethodError
|
10
10
|
raise "#{@delegator} does not respond to #{@to}!"
|
11
11
|
end
|
12
|
-
allow(@delegator).to receive(@to).and_return(double(
|
12
|
+
allow(@delegator).to receive(@to).and_return(double("receiver", method => :called))
|
13
13
|
actual = (@delegator.send(@method) == :called)
|
14
14
|
allow(@delegator).to receive(@to).and_call_original # unstub
|
15
15
|
actual
|
16
16
|
end
|
17
17
|
|
18
18
|
description do
|
19
|
-
"delegate :#{@method} to its #{@to}#{@prefix ?
|
19
|
+
"delegate :#{@method} to its #{@to}#{@prefix ? " with prefix" : ""}"
|
20
20
|
end
|
21
21
|
|
22
22
|
failure_message do |_text|
|
23
|
-
"expected #{@delegator} to delegate :#{@method} to its #{@to}#{@prefix ?
|
23
|
+
"expected #{@delegator} to delegate :#{@method} to its #{@to}#{@prefix ? " with prefix" : ""}"
|
24
24
|
end
|
25
25
|
|
26
26
|
failure_message_when_negated do |_text|
|
27
|
-
"expected #{@delegator} not to delegate :#{@method} to its #{@to}#{@prefix ?
|
27
|
+
"expected #{@delegator} not to delegate :#{@method} to its #{@to}#{@prefix ? " with prefix" : ""}"
|
28
28
|
end
|
29
29
|
|
30
30
|
chain(:to) { |receiver| @to = receiver }
|
data/spec/message_spec.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "spec_helper"
|
4
|
+
require "json"
|
5
5
|
|
6
6
|
RSpec.describe FastlyNsq::Message do
|
7
|
-
let(:nsq_message) { double
|
8
|
-
let(:body)
|
9
|
-
let(:json_body)
|
10
|
-
subject
|
7
|
+
let(:nsq_message) { double "Nsq::Message", body: json_body, attempts: 1, finish: nil, requeue: nil, touch: nil, timestamp: nil, id: nil }
|
8
|
+
let(:body) { {"data" => "goes here", "other_field" => "is over here", "meta" => "meta stuff"} }
|
9
|
+
let(:json_body) { body.to_json }
|
10
|
+
subject { FastlyNsq::Message.new nsq_message }
|
11
11
|
|
12
|
-
it
|
12
|
+
it "preserves original message body as raw_body" do
|
13
13
|
expect(subject.raw_body).to eq(json_body)
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it "presents parsed message body as body" do
|
17
17
|
expect(subject.body).to eq(body)
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
expect(subject.data).to eq(
|
20
|
+
it "plucks data as data" do
|
21
|
+
expect(subject.data).to eq("goes here")
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
25
|
-
expect(subject.meta).to eq(body[
|
24
|
+
it "plucks meta as meta" do
|
25
|
+
expect(subject.meta).to eq(body["meta"])
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it "aliases raw_body to to_s" do
|
29
29
|
expect(subject.to_s).to eq(json_body)
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it "delegates methods to the nsq_message object" do
|
33
33
|
%w[attempts finish requeue touch timestamp id].each do |method|
|
34
34
|
subject = FastlyNsq::Message.new nsq_message
|
35
35
|
expect(nsq_message).to receive(method)
|
@@ -38,7 +38,7 @@ RSpec.describe FastlyNsq::Message do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it "does not finish if the message was requeued" do
|
42
42
|
expect(nsq_message).to receive(:requeue).with(1000)
|
43
43
|
expect(nsq_message).not_to receive(:finish)
|
44
44
|
|
@@ -48,7 +48,7 @@ RSpec.describe FastlyNsq::Message do
|
|
48
48
|
expect(subject.managed).to eq(:requeued)
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
51
|
+
it "does not requeue if the message was finished" do
|
52
52
|
expect(nsq_message).to receive(:finish)
|
53
53
|
expect(nsq_message).not_to receive(:requeue)
|
54
54
|
|
@@ -58,19 +58,19 @@ RSpec.describe FastlyNsq::Message do
|
|
58
58
|
expect(subject.managed).to eq(:finished)
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
61
|
+
it "uses the passed timeout for the requeue timeout" do
|
62
62
|
expect(nsq_message).to receive(:requeue).with(1000)
|
63
63
|
|
64
64
|
subject.requeue(1000)
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
67
|
+
it "uses exponential backoff for timeout if none is given" do
|
68
68
|
expect(nsq_message).to receive(:requeue).with(46_000..166_000)
|
69
69
|
|
70
70
|
subject.requeue
|
71
71
|
end
|
72
72
|
|
73
|
-
it
|
73
|
+
it "uses the FastlyNsq.max_req_timeout it timeout is larger than FastlyNsq.max_req_timeout" do
|
74
74
|
expect(nsq_message).to receive(:requeue).with(60 * 60 * 1_000)
|
75
75
|
|
76
76
|
subject.requeue(60 * 60 * 4 * 1_000)
|