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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03fbb1644325f6357fad234932a15ad97e7d432b
4
- data.tar.gz: 070e6c0fe34dbabd2184f5de8be59a52cc50e111
3
+ metadata.gz: a3a42709debb8a573f27df0efdb01b0ff2c30c01
4
+ data.tar.gz: 4abd037e9a15eebb9c442a48fdc6c76a7fdd5536
5
5
  SHA512:
6
- metadata.gz: a27648b9853176003f2fcd333e0f237f47e71e5452900894e3615aaa9975be5e19d38f12a3ee42b9d016e68a8a4cb96ed7b4448e962a240c9dc505cf6b9a7a7b
7
- data.tar.gz: c4824d03aa286a62482f9135b7ad25796e6e4b67c3e0385dd86d6c083300ccbfe545eac2027c7ec126ff71d375ff533b4d315cac2da375e16734c1d3d3d8649c
6
+ metadata.gz: 3059ee3d302f936190ba3f5992fde033f8854ba7b3bf5bdd79628db891e07fdb1bdb6afcb0c19645a4281b41891520db1a2fdcae12a23deeebcadac9498b0737
7
+ data.tar.gz: 16f02d1c0238c80b7820761664d29125f6505175b4095ecd53f132711d8d3bc4b7a3006ffb84421b8f36f36fb93e5df4c50d8ae633ed00d99967eba148e85522
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.1.8
5
4
  - 2.2.4
6
- - 2.3.0
5
+ - 2.3.5
6
+ - 2.4.2
7
7
  script:
8
8
  - bundle exec rake
9
9
  notifications:
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.12.3 / 2017-11-02
2
+
3
+ * Remove initialization Timeout on Consumer Connections
4
+
1
5
  ### 0.9.0 / 2016-12-20
2
6
 
3
7
  * Add FastlyNsq::Messenger to persist Producers
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
@@ -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]'
@@ -13,13 +13,11 @@ module FastlyNsq
13
13
  @channel = channel
14
14
  @tls_options = TlsOptions.as_hash(tls_options)
15
15
  @connector = connector
16
- Timeout.timeout(5) do
17
- sleep(0.1) until connection.connected?
18
- end
19
- rescue Timeout::Error => error
20
- FastlyNsq.logger.error "Consumer for #{topic} failed to connect!"
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
@@ -83,6 +83,10 @@ module FastlyNsq
83
83
  queue.size
84
84
  end
85
85
 
86
+ def empty?
87
+ queue.empty?
88
+ end
89
+
86
90
  def terminate
87
91
  # noop
88
92
  end
@@ -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, 10)
27
+ deadline = Time.now + @options.fetch(:timeout, 5)
28
28
  quiet
29
29
  @manager.stop deadline
30
30
  end
@@ -72,7 +72,8 @@ module FastlyNsq
72
72
  cleanup
73
73
  return unless @thread
74
74
  @logger.info "< Listener TERM: topic #{@topic}"
75
- @thread.raise FastlyNsq::Shutdown
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
@@ -1,3 +1,3 @@
1
1
  module FastlyNsq
2
- VERSION = '0.12.2'.freeze
2
+ VERSION = '0.12.4'.freeze
3
3
  end
@@ -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 + 10)
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.2
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-09-12 00:00:00.000000000 Z
14
+ date: 2017-11-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: awesome_print