fastly_nsq 1.1.0 → 1.2.0

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: e4e14c6f6e81b0ab2e649f1dccd22288fbe77d67
4
- data.tar.gz: 82e1b772253cf8c9d2b9db9871beaf9f3895f95e
3
+ metadata.gz: 553d58c7ebd2909c851799e269e6ad6d4ef1ad6f
4
+ data.tar.gz: b99a102f8a6659a3c325c1ae79a9e5c03876745c
5
5
  SHA512:
6
- metadata.gz: 9e094b21ee8404ff5ba792265c9148820062dbe75ce611c803c57ad02ebdf2bb5d89ee76dd51781b894f98e4d5b2ca48210ef24f1709ae3353dfd67e58d1f202
7
- data.tar.gz: 9e3444babd610129939d33d6572549540b42a07f9f9d3bdabd585f4dedd8af5dc17154dcd67bd0cc5c8397b28dbc311ad690a59106aec044ebe49c2113b82de3
6
+ metadata.gz: cecf8dc69439bdbe7e05cae3fbbce5862ee42fdb947f177e4480bb464f9b7fd925ec099151164833d24ddf3dba51dffa06b270375422a7e7c9dc7f8c104a5d7c
7
+ data.tar.gz: 92f7c3759578cec172c5ef6851cf9993cf1b5ee33b15baa338918044ca0e3d05f867c2641f66f6946e4ddebdb8f9373fddec7fb3afc39d9eddd50aa56b334e0b
@@ -29,6 +29,6 @@ Gem::Specification.new do |gem|
29
29
  gem.add_development_dependency 'webmock', '~> 3.0'
30
30
 
31
31
  gem.add_dependency 'concurrent-ruby', '~> 1.0'
32
- gem.add_dependency 'nsq-ruby', '~> 2.2'
32
+ gem.add_dependency 'nsq-ruby', '~> 2.3'
33
33
  gem.add_dependency 'priority_queue_cxx', '~> 0.3'
34
34
  end
@@ -9,13 +9,13 @@ class FastlyNsq::Consumer
9
9
 
10
10
  def_delegators :connection, :size, :terminate, :connected?, :pop, :pop_without_blocking
11
11
 
12
- def initialize(topic:, channel:, queue: nil, tls_options: nil, connect_timeout: DEFAULT_CONNECTION_TIMEOUT)
12
+ def initialize(topic:, channel:, queue: nil, tls_options: nil, connect_timeout: DEFAULT_CONNECTION_TIMEOUT, **options)
13
13
  @topic = topic
14
14
  @channel = channel
15
15
  @tls_options = FastlyNsq::TlsOptions.as_hash(tls_options)
16
16
  @connect_timeout = connect_timeout
17
17
 
18
- @connection = connect(queue)
18
+ @connection = connect(queue, **options)
19
19
  end
20
20
 
21
21
  def empty?
@@ -26,13 +26,14 @@ class FastlyNsq::Consumer
26
26
 
27
27
  attr_reader :tls_options
28
28
 
29
- def connect(queue)
29
+ def connect(queue, **options)
30
30
  Nsq::Consumer.new(
31
31
  {
32
32
  nsqlookupd: FastlyNsq.lookupd_http_addresses,
33
33
  topic: topic,
34
34
  channel: channel,
35
35
  queue: queue,
36
+ **options,
36
37
  }.merge(tls_options),
37
38
  )
38
39
  end
@@ -11,7 +11,8 @@ class FastlyNsq::Listener
11
11
  attr_reader :preprocessor, :topic, :processor, :priority, :channel, :logger, :consumer
12
12
 
13
13
  def initialize(topic:, processor:, preprocessor: FastlyNsq.preprocessor, channel: FastlyNsq.channel, consumer: nil,
14
- logger: FastlyNsq.logger, priority: DEFAULT_PRIORITY, connect_timeout: DEFAULT_CONNECTION_TIMEOUT)
14
+ logger: FastlyNsq.logger, priority: DEFAULT_PRIORITY, connect_timeout: DEFAULT_CONNECTION_TIMEOUT,
15
+ **consumer_options)
15
16
 
16
17
  raise ArgumentError, "processor #{processor.inspect} does not respond to #call" unless processor.respond_to?(:call)
17
18
  raise ArgumentError, "priority #{priority.inspect} must be a Integer" unless priority.is_a?(Integer)
@@ -26,7 +27,8 @@ class FastlyNsq::Listener
26
27
  @consumer = consumer || FastlyNsq::Consumer.new(topic: topic,
27
28
  connect_timeout: connect_timeout,
28
29
  channel: channel,
29
- queue: FastlyNsq::Feeder.new(self, priority))
30
+ queue: FastlyNsq::Feeder.new(self, priority),
31
+ **consumer_options)
30
32
 
31
33
  FastlyNsq.manager.add_listener(self)
32
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastlyNsq
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -15,6 +15,18 @@ RSpec.describe FastlyNsq::Listener do
15
15
  subject { described_class.new(topic: topic, channel: channel, processor: processor) }
16
16
 
17
17
  describe '#initialize' do
18
+ describe 'max_attempts' do
19
+ it 'can be passed to the consumer' do
20
+ listener = described_class.new topic: topic,
21
+ processor: processor,
22
+ channel: channel,
23
+ max_attempts: 5
24
+ expect { listener }.to eventually(be_connected).within(5)
25
+ nsq_connection = listener.consumer.connection.connections.values.first # whoa
26
+ expect(nsq_connection.instance_variable_get(:@max_attempts)).to eq(5)
27
+ end
28
+ end
29
+
18
30
  describe 'with FastlyNsq.channel set' do
19
31
  let!(:default_channel) { FastlyNsq.channel }
20
32
  before { FastlyNsq.channel = 'fnsq' }
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.1.0
4
+ version: 1.2.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-02-20 00:00:00.000000000 Z
16
+ date: 2018-04-11 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: awesome_print
@@ -133,14 +133,14 @@ dependencies:
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '2.2'
136
+ version: '2.3'
137
137
  type: :runtime
138
138
  prerelease: false
139
139
  version_requirements: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '2.2'
143
+ version: '2.3'
144
144
  - !ruby/object:Gem::Dependency
145
145
  name: priority_queue_cxx
146
146
  requirement: !ruby/object:Gem::Requirement
@@ -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.6.14
242
+ rubygems_version: 2.5.1
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: Fastly NSQ Adapter