fastly_nsq 0.12.2 → 0.12.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/ChangeLog.md +4 -0
- data/README.md +1 -1
- data/lib/fastly_nsq/cli.rb +4 -0
- data/lib/fastly_nsq/consumer.rb +5 -7
- data/lib/fastly_nsq/fake_backend.rb +4 -0
- data/lib/fastly_nsq/launcher.rb +1 -1
- data/lib/fastly_nsq/listener.rb +2 -1
- data/lib/fastly_nsq/version.rb +1 -1
- data/spec/lib/fastly_nsq/launcher_spec.rb +2 -2
- data/spec/lib/fastly_nsq/listener_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3a42709debb8a573f27df0efdb01b0ff2c30c01
|
4
|
+
data.tar.gz: 4abd037e9a15eebb9c442a48fdc6c76a7fdd5536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3059ee3d302f936190ba3f5992fde033f8854ba7b3bf5bdd79628db891e07fdb1bdb6afcb0c19645a4281b41891520db1a2fdcae12a23deeebcadac9498b0737
|
7
|
+
data.tar.gz: 16f02d1c0238c80b7820761664d29125f6505175b4095ecd53f132711d8d3bc4b7a3006ffb84421b8f36f36fb93e5df4c50d8ae633ed00d99967eba148e85522
|
data/.travis.yml
CHANGED
data/ChangeLog.md
CHANGED
data/README.md
CHANGED
@@ -170,7 +170,7 @@ block. An exmaple of this can be found here: [`Example Config`](exmaple_config_c
|
|
170
170
|
|
171
171
|
An example of using the cli:
|
172
172
|
```bash
|
173
|
-
./bin/fastly_nsq -r ./example_config_class.rb -L ./test.log -P ./fastly_nsq.pid -v -d
|
173
|
+
./bin/fastly_nsq -r ./example_config_class.rb -L ./test.log -P ./fastly_nsq.pid -v -d -t 4
|
174
174
|
```
|
175
175
|
|
176
176
|
### FastlyNsq::Messgener
|
data/lib/fastly_nsq/cli.rb
CHANGED
@@ -92,6 +92,10 @@ class FastlyNsq::CLI
|
|
92
92
|
o.on '-v', '--verbose', 'enable verbose logging output' do |arg|
|
93
93
|
opts[:verbose] = arg
|
94
94
|
end
|
95
|
+
|
96
|
+
o.on '-t', '--timeout SECONDS', 'shutdown deadline timeout' do |arg|
|
97
|
+
opts[:timeout] = arg
|
98
|
+
end
|
95
99
|
end
|
96
100
|
|
97
101
|
@parser.banner = 'fastly_nsq [options]'
|
data/lib/fastly_nsq/consumer.rb
CHANGED
@@ -13,13 +13,11 @@ module FastlyNsq
|
|
13
13
|
@channel = channel
|
14
14
|
@tls_options = TlsOptions.as_hash(tls_options)
|
15
15
|
@connector = connector
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
connection.terminate
|
22
|
-
raise error
|
16
|
+
connection
|
17
|
+
end
|
18
|
+
|
19
|
+
def empty?
|
20
|
+
connection.size == 0 # rubocop:disable ZeroLengthPredicate
|
23
21
|
end
|
24
22
|
|
25
23
|
private
|
data/lib/fastly_nsq/launcher.rb
CHANGED
@@ -24,7 +24,7 @@ class FastlyNsq::Launcher
|
|
24
24
|
# return until all work is complete and cleaned up.
|
25
25
|
# It can take up to the timeout to complete.
|
26
26
|
def stop
|
27
|
-
deadline = Time.now + @options.fetch(:timeout,
|
27
|
+
deadline = Time.now + @options.fetch(:timeout, 5)
|
28
28
|
quiet
|
29
29
|
@manager.stop deadline
|
30
30
|
end
|
data/lib/fastly_nsq/listener.rb
CHANGED
@@ -72,7 +72,8 @@ module FastlyNsq
|
|
72
72
|
cleanup
|
73
73
|
return unless @thread
|
74
74
|
@logger.info "< Listener TERM: topic #{@topic}"
|
75
|
-
|
75
|
+
# Interrupt a Consumer blocking in pop with no messages otherwise it will never shutdown
|
76
|
+
@thread.raise FastlyNsq::Shutdown if @consumer.empty?
|
76
77
|
end
|
77
78
|
|
78
79
|
def kill
|
data/lib/fastly_nsq/version.rb
CHANGED
@@ -5,7 +5,7 @@ RSpec.describe FastlyNsq::Launcher do
|
|
5
5
|
let(:launcher) { FastlyNsq::Launcher.new options }
|
6
6
|
let(:manager) { instance_double 'Manager', start: nil, quiet: nil, stop: nil }
|
7
7
|
let(:thread) { instance_double 'Thread' }
|
8
|
-
let(:options) { { joe: 'biden' } }
|
8
|
+
let(:options) { { joe: 'biden', timeout: 9 } }
|
9
9
|
|
10
10
|
before do
|
11
11
|
allow(FastlyNsq::Manager).to receive(:new).and_return(manager)
|
@@ -44,7 +44,7 @@ RSpec.describe FastlyNsq::Launcher do
|
|
44
44
|
now = Time.now
|
45
45
|
allow(Time).to receive(:now).and_return(now)
|
46
46
|
launcher.stop
|
47
|
-
expect(manager).to have_received(:stop).with(now +
|
47
|
+
expect(manager).to have_received(:stop).with(now + options[:timeout])
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'quites the manager' do
|
@@ -178,6 +178,23 @@ RSpec.describe FastlyNsq::Listener do
|
|
178
178
|
expect(state).to eq true
|
179
179
|
end
|
180
180
|
|
181
|
+
it 'raise in terminate to interupt blocking on an empty queue' do
|
182
|
+
listener.start
|
183
|
+
listener.terminate
|
184
|
+
|
185
|
+
expect(consumer.empty?).to be true
|
186
|
+
expect(thread).to have_received(:raise)
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'terminate allows messages to be completed' do
|
190
|
+
100.times { FastlyNsq::Messenger.deliver(on_topic: topic, message: 'test_message') }
|
191
|
+
listener.start
|
192
|
+
listener.terminate
|
193
|
+
|
194
|
+
expect(consumer.empty?).to be false
|
195
|
+
expect(thread).to_not have_received(:raise)
|
196
|
+
end
|
197
|
+
|
181
198
|
it 'can be killed' do
|
182
199
|
listener.start
|
183
200
|
state = listener.instance_variable_get(:@done)
|
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: 0.12.
|
4
|
+
version: 0.12.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy O'Neil
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-11-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: awesome_print
|