fastly_nsq 1.13.0 → 1.17.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
  SHA256:
3
- metadata.gz: 8a96d39aaf8bfa8168a11523a097d7b06231d38f46f152d2b2432e07f51e7f69
4
- data.tar.gz: 5107261e47c9c8786a86aff6369868acd98895e0e04b0745e6f31da1ac85f42b
3
+ metadata.gz: 0a0de08856671c960970c164a3b95efdaef29bfb05ba2c8282cbc81d0e3d8282
4
+ data.tar.gz: bb52cbe4e13ca5bce686409eb20c7f13fd1975f41da73cc14a231a94d737a80c
5
5
  SHA512:
6
- metadata.gz: e4d4bd99d0789eafcc85826942b564d541ad760c9d7c64892cb7627a38984493b5812e02d73fe93b8ce9580a28c9f5f4abf6ac9e86f5e87823d349af87e4d493
7
- data.tar.gz: 25c21fcee5324ca0cb16be4fde1dd4cc434d90c7d0dc9da6fdb5158ced9b2d6e978b33799aff3aecb52fad67b84686637309b543f787adf7625ad7f984931931
6
+ metadata.gz: 71ed32139074cf89fdb848675df2b52a9a62dc76d3a9027f78620c9656791c580e2132a4ab06bbdcfe726c42a7b22e54b85c5fe3096cbcfbe4a32ee68c8cf9e8
7
+ data.tar.gz: fc1b312239fa56c20f49e37dbf999b8decedff1532b1882be3358e524ff14cdc4e0091c727f1ac11d378cb71ba8112dab61fc0736dd9db063baa11cfc6f4f674
data/.travis.yml CHANGED
@@ -2,7 +2,6 @@ language: ruby
2
2
  cache: bundler
3
3
  sudo: false
4
4
  rvm:
5
- - 2.3.5
6
5
  - 2.4.2
7
6
  - 2.5.1
8
7
  script:
data/ChangeLog.md CHANGED
@@ -1,7 +1,44 @@
1
1
  # Change Log
2
2
 
3
- ## [v1.13.0](https://github.com/fastly/fastly_nsq/tree/v1.13.0)
3
+ ## [v1.17.0](https://github.com/fastly/fastly_nsq/tree/v1.17.0) (2021-02-11)
4
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.16.0...v1.17.0)
4
5
 
6
+ **Merged pull requests:**
7
+
8
+ - Support for arbitary sent\_at Time [\#99](https://github.com/fastly/fastly_nsq/pull/99) ([leklund](https://github.com/leklund))
9
+ - remove version pin on rake for development [\#97](https://github.com/fastly/fastly_nsq/pull/97) ([leklund](https://github.com/leklund))
10
+ - Ignore from Humane Registry [\#96](https://github.com/fastly/fastly_nsq/pull/96) ([leklund](https://github.com/leklund))
11
+
12
+ ## [v1.16.0](https://github.com/fastly/fastly_nsq/tree/v1.16.0) (2019-08-16)
13
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.15.0...v1.16.0)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - Log the internal NSQ id [\#95](https://github.com/fastly/fastly_nsq/pull/95) ([leklund](https://github.com/leklund))
18
+ - Consumer still attempts connections in Test mode [\#93](https://github.com/fastly/fastly_nsq/pull/93) ([alieander](https://github.com/alieander))
19
+
20
+ ## [v1.15.0](https://github.com/fastly/fastly_nsq/tree/v1.15.0) (2018-10-05)
21
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.14.0...v1.15.0)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - Add support for configuring max\_threads [\#94](https://github.com/fastly/fastly_nsq/pull/94) ([leklund](https://github.com/leklund))
26
+
27
+ ## [v1.14.0](https://github.com/fastly/fastly_nsq/tree/v1.14.0) (2018-08-13)
28
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.13.1...v1.14.0)
29
+
30
+ **Merged pull requests:**
31
+
32
+ - set Nsq.logger when setting logger [\#92](https://github.com/fastly/fastly_nsq/pull/92) ([leklund](https://github.com/leklund))
33
+
34
+ ## [v1.13.1](https://github.com/fastly/fastly_nsq/tree/v1.13.1) (2018-07-27)
35
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.13.0...v1.13.1)
36
+
37
+ **Merged pull requests:**
38
+
39
+ - Fix class\_name for NewRelic reporting [\#91](https://github.com/fastly/fastly_nsq/pull/91) ([leklund](https://github.com/leklund))
40
+
41
+ ## [v1.13.0](https://github.com/fastly/fastly_nsq/tree/v1.13.0) (2018-07-27)
5
42
  [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.12.0...v1.13.0)
6
43
 
7
44
  **Merged pull requests:**
@@ -390,18 +427,18 @@
390
427
  - Initialize the fake queue with an empty array [\#4](https://github.com/fastly/fastly_nsq/pull/4) ([adarsh](https://github.com/adarsh))
391
428
 
392
429
  ## [v0.1.3](https://github.com/fastly/fastly_nsq/tree/v0.1.3) (2016-02-03)
393
- [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.1.1...v0.1.3)
430
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.0.2...v0.1.3)
394
431
 
395
432
  **Merged pull requests:**
396
433
 
397
434
  - Use a more canonical way to require files [\#3](https://github.com/fastly/fastly_nsq/pull/3) ([adarsh](https://github.com/adarsh))
398
435
  - Remove dependancy on ActiveSupport [\#2](https://github.com/fastly/fastly_nsq/pull/2) ([adarsh](https://github.com/adarsh))
399
436
 
400
- ## [v0.1.1](https://github.com/fastly/fastly_nsq/tree/v0.1.1) (2016-02-03)
401
- [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.0.2...v0.1.1)
402
-
403
437
  ## [v0.0.2](https://github.com/fastly/fastly_nsq/tree/v0.0.2) (2016-02-03)
404
- [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.0.1...v0.0.2)
438
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.1.1...v0.0.2)
439
+
440
+ ## [v0.1.1](https://github.com/fastly/fastly_nsq/tree/v0.1.1) (2016-02-03)
441
+ [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.0.1...v0.1.1)
405
442
 
406
443
  **Merged pull requests:**
407
444
 
@@ -410,4 +447,4 @@
410
447
  ## [v0.0.1](https://github.com/fastly/fastly_nsq/tree/v0.0.1) (2016-01-30)
411
448
 
412
449
 
413
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
450
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile CHANGED
@@ -4,10 +4,10 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'bundler-audit', '~> 0.5.0'
7
+ gem 'bundler-audit'
8
8
  gem 'newrelic_rpm', require: false
9
9
  gem 'overcommit', '~> 0.32.0'
10
- gem 'rake', '~> 11.1.2'
11
- gem 'rdoc', '~> 4.2.2'
10
+ gem 'rake'
11
+ gem 'rdoc'
12
12
  gem 'rubocop', '~> 0.51.0'
13
13
  gem 'rubygems-tasks', '~> 0.2'
data/README.md CHANGED
@@ -159,6 +159,7 @@ FastlyNsq.configure do |config|
159
159
 
160
160
  config.max_attempts = 20
161
161
  config.max_req_timeout = (60 * 60 * 4 * 1_000) # 4 hours
162
+ config.max_processing_pool_threads = 10
162
163
 
163
164
  lc.listen 'posts', ->(m) { puts "posts: #{m.body}" }
164
165
  lc.listen 'blogs', ->(m) { puts "blogs: #{m.body}" }, priority: 3
@@ -333,3 +334,7 @@ You will still need the `ENV` variables as defined above.
333
334
  Copyright (c) 2016 [Fastly, Inc](https://fastly.com) under an MIT license.
334
335
 
335
336
  See [LICENSE.txt](LICENSE.txt) for details.
337
+
338
+ # Metadata
339
+
340
+ - Ignore
data/fastly_nsq.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.require_paths = ['lib']
22
22
 
23
23
  gem.add_development_dependency 'awesome_print', '~> 1.6'
24
- gem.add_development_dependency 'bundler', '~> 1.12'
24
+ gem.add_development_dependency 'bundler'
25
25
  gem.add_development_dependency 'dotenv'
26
26
  gem.add_development_dependency 'pry-byebug', '~> 3.3'
27
27
  gem.add_development_dependency 'rspec', '~> 3.4'
data/lib/fastly_nsq.rb CHANGED
@@ -30,8 +30,9 @@ module FastlyNsq
30
30
  # @return [Integer]
31
31
  attr_writer :max_req_timeout
32
32
 
33
- # @return [Logger]
34
- attr_writer :logger
33
+ # Maximum number of threads for FastlyNsq::PriorityThreadPool
34
+ # @return [Integer]
35
+ attr_writer :max_processing_pool_threads
35
36
 
36
37
  ##
37
38
  # Map of lifecycle events
@@ -51,8 +52,20 @@ module FastlyNsq
51
52
  FastlyNsq::Listener.new(topic: topic, processor: processor, **options)
52
53
  end
53
54
 
55
+ ##
56
+ # Return logger or set logger to default.
57
+ # @return [Logger]
54
58
  def logger
55
- @logger ||= Logger.new(nil)
59
+ return @logger if @logger
60
+
61
+ self.logger = Logger.new(STDERR)
62
+ end
63
+
64
+ ##
65
+ # Set the logger and also set Nsq.logger
66
+ # @params logger [Logger]
67
+ def logger=(new_logger)
68
+ @logger = Nsq.logger = new_logger
56
69
  end
57
70
 
58
71
  ##
@@ -102,6 +115,13 @@ module FastlyNsq
102
115
  @max_req_timeout ||= ENV.fetch('MAX_REQ_TIMEOUT', 60 * 60 * 1_000).to_i
103
116
  end
104
117
 
118
+ # Maximum number of threads for FastlyNsq::PriorityThreadPool
119
+ # Default setting is 5 and can be set via ENV['MAX_PROCESSING_POOL_THREADS']
120
+ # @return [Integer]
121
+ def max_processing_pool_threads
122
+ @max_processing_pool_threads ||= ENV.fetch('MAX_PROCESSING_POOL_THREADS', 5).to_i
123
+ end
124
+
105
125
  ##
106
126
  # Return an array of NSQ lookupd http addresses sourced from ENV['NSQLOOKUPD_HTTP_ADDRESS']
107
127
  # @return [Array<String>] list of nsqlookupd http addresses
@@ -32,7 +32,7 @@ class FastlyNsq::Feeder
32
32
  # swallow the exception.
33
33
  #
34
34
  # @param message [Nsq::Message]
35
- # @see http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ThreadPoolExecutor.html#post-instance_method
35
+ # @see http://ruby-concurrency.github.io/concurrent-ruby/1.0.5/Concurrent/ThreadPoolExecutor.html#post-instance_method
36
36
  # @see Nsq::Connection#read_loop
37
37
  def push(message)
38
38
  FastlyNsq.manager.pool.post(priority) do
@@ -116,8 +116,9 @@ class FastlyNsq::Listener
116
116
  msg_info = {
117
117
  channel: channel,
118
118
  topic: topic,
119
- attempts: nsq_message.attempts,
119
+ attempts: message.attempts,
120
120
  id: Digest::MD5.hexdigest(nsq_message.body.to_s),
121
+ nsq_id: message.id,
121
122
  metadata: message.meta,
122
123
  }
123
124
 
@@ -129,7 +130,9 @@ class FastlyNsq::Listener
129
130
  end
130
131
  end
131
132
 
132
- FastlyNsq.tracer.trace_with_newrelic(params: msg_info, class_name: processor.class.to_s) do
133
+ class_name = processor.is_a?(Class) ? processor.name : processor.class.name
134
+
135
+ FastlyNsq.tracer.trace_with_newrelic(params: msg_info, class_name: class_name) do
133
136
  preprocessor&.call(message)
134
137
  result = processor.call(message)
135
138
  message.finish if result
@@ -4,7 +4,6 @@
4
4
  # Interface for tracking listeners and managing the processing pool.
5
5
  class FastlyNsq::Manager
6
6
  DEADLINE = 30
7
- DEFAULT_POOL_SIZE = 5
8
7
 
9
8
  # @return [Boolean] Set true when all listeners are stopped
10
9
  attr_reader :done
@@ -19,12 +18,13 @@ class FastlyNsq::Manager
19
18
  # Create a FastlyNsq::Manager
20
19
  #
21
20
  # @param logger [Logger]
21
+ # @param max_threads [Integer] Maxiumum number of threads to be used by {FastlyNsq::PriorityThreadPool}
22
22
  # @param pool_options [Hash] Options forwarded to {FastlyNsq::PriorityThreadPool} constructor.
23
- def initialize(logger: FastlyNsq.logger, **pool_options)
23
+ def initialize(logger: FastlyNsq.logger, max_threads: FastlyNsq.max_processing_pool_threads, **pool_options)
24
24
  @done = false
25
25
  @logger = logger
26
26
  @pool = FastlyNsq::PriorityThreadPool.new(
27
- { fallback_policy: :caller_runs, max_threads: DEFAULT_POOL_SIZE }.merge(pool_options),
27
+ { fallback_policy: :caller_runs, max_threads: max_threads }.merge(pool_options),
28
28
  )
29
29
  end
30
30
 
@@ -20,7 +20,11 @@ class FastlyNsq::Message
20
20
  # Delegated to +self.nsq_message+
21
21
  # @return [Nsq::Message#timestamp]
22
22
  # @see https://www.rubydoc.info/gems/nsq-ruby/Nsq/Message#timestamp-instance_method
23
- def_delegators :@nsq_message, :attempts, :touch, :timestamp
23
+ # @!method id
24
+ # Delegated to +self.nsq_message+
25
+ # @return [Nsq::Message#id]
26
+ # @see https://www.rubydoc.info/gems/nsq-ruby/Nsq/Message#id-instance_method
27
+ def_delegators :@nsq_message, :attempts, :touch, :timestamp, :id
24
28
 
25
29
  # @return [Symbol] Message state. Returns +nil+ if message has not been requeued or finished.
26
30
  attr_reader :managed
@@ -18,23 +18,26 @@ module FastlyNsq::Messenger
18
18
  ##
19
19
  # Deliver an NSQ message. Uses +pub+
20
20
  #
21
- # Will add two keys to the `+meta+ payload that cannot be overidden:
22
- # +originating_service+ which defaults to {FastlyNsq#originating_service} and
23
- # +sent_at+ which will be set to +Time.now.iso8601(5)+ when the payload is created.
21
+ # Adds keys to the `+meta+:
22
+ # +originating_service+ which defaults to {FastlyNsq#originating_service}.
23
+ # +sent_at+ which will be set to +Time.now.iso8601(5)+ if the +sent_at+ param is nil OR
24
+ # if the passed +sent_at+ is not a valid timestamp.
24
25
  # @param message [#to_json(*)] written to the +data+ key of the NSQ message payload
25
26
  # @param topic [String] NSQ topic on which to deliver the message
26
27
  # @param originating_service [String] added to meta key of message payload
28
+ # @param sent_at [Time] Timestamp that will be added to the meta payload
27
29
  # @param meta [Hash]
28
30
  # @return [Void]
29
31
  # @example
30
32
  # FastlyNsq::Messenger.deliver(
31
33
  # message: {a: 1, count: 123},
32
34
  # topic: 'count',
35
+ # meta: { sent_at: Time.now }
33
36
  # )
34
- def deliver(message:, topic:, originating_service: nil, meta: {})
37
+ def deliver(message:, topic:, originating_service: nil, sent_at: nil, meta: {})
35
38
  payload = {
36
39
  data: message,
37
- meta: populate_meta(originating_service: originating_service, meta: meta),
40
+ meta: populate_meta(originating_service: originating_service, sent_at: sent_at, meta: meta),
38
41
  }
39
42
 
40
43
  deliver_payload(topic: topic, payload: payload.to_json)
@@ -43,15 +46,16 @@ module FastlyNsq::Messenger
43
46
  ##
44
47
  # Deliver many NSQ messages at once. Uses +mpub+
45
48
  #
46
- # For each message will add two keys to the `+meta+ payload of each message
47
- # that cannot be overidden:
48
- # +originating_service+ which defaults to {FastlyNsq#originating_service} and
49
- # +sent_at+ which will be set to +Time.now.iso8601(5)+ when messages are processed.
49
+ # For each message will add two keys to the `+meta+ payload of each message:
50
+ # +originating_service+ which defaults to {FastlyNsq#originating_service}
51
+ # +sent_at+ which will be set to +Time.now.iso8601(5)+ when messages are processed if not included
52
+ # in the +meta+ param OR if the pased +sent_at+ is not a valid timestamp.
50
53
  # The +sent_at+ time and +originating_service+ will be the same for every message.
51
54
  # @param messages [Array] Array of message which will be written to +data+ key of the
52
55
  # individual NSQ message payload. Each message needs to respond to +to_json(*)+.
53
56
  # @param topic [String] NSQ topic on which to deliver the message
54
57
  # @param originating_service [String] added to meta key of message payload
58
+ # @param sent_at [Time] Timestamp that will be added to the meta payload
55
59
  # @param meta [Hash]
56
60
  # @return [Void]
57
61
  # @example
@@ -59,8 +63,8 @@ module FastlyNsq::Messenger
59
63
  # messages: [{a: 1, count: 11}, {a: 2, count: 22}],
60
64
  # topic: 'counts',
61
65
  # )
62
- def deliver_multi(messages:, topic:, originating_service: nil, meta: {})
63
- meta = populate_meta(originating_service: originating_service, meta: meta)
66
+ def deliver_multi(messages:, topic:, originating_service: nil, sent_at: nil, meta: {})
67
+ meta = populate_meta(originating_service: originating_service, sent_at: sent_at, meta: meta)
64
68
 
65
69
  payload = messages.each_with_object([]) do |message, a|
66
70
  msg = {
@@ -121,9 +125,15 @@ module FastlyNsq::Messenger
121
125
  producer_for(topic: topic) { |producer| producer.write payload }
122
126
  end
123
127
 
124
- def populate_meta(originating_service: nil, meta: {})
128
+ def populate_meta(originating_service: nil, sent_at: nil, meta: {})
125
129
  meta[:originating_service] = originating_service || self.originating_service
126
- meta[:sent_at] = Time.now.iso8601(5)
130
+
131
+ meta[:sent_at] = if sent_at && sent_at.respond_to?(:iso8601)
132
+ sent_at.iso8601(5)
133
+ else
134
+ Time.now.iso8601(5)
135
+ end
136
+
127
137
  meta
128
138
  end
129
139
  end
@@ -249,6 +249,10 @@ module FastlyNsq
249
249
 
250
250
  FastlyNsq::Listener.prepend(ListenerTesting)
251
251
 
252
+ class FakeConnection
253
+ def connected?; end
254
+ end
255
+
252
256
  module ConsumerTesting
253
257
  module ClassMethods
254
258
  def messages(topic = nil)
@@ -278,6 +282,11 @@ module FastlyNsq
278
282
  @connected
279
283
  end
280
284
 
285
+ def connect(*args)
286
+ return super(*args) unless FastlyNsq::Testing.enabled?
287
+ @connected = FakeConnection.new
288
+ end
289
+
281
290
  def empty?
282
291
  FastlyNsq::Testing.enabled? ? messages.empty? : super
283
292
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastlyNsq
4
- VERSION = '1.13.0'
4
+ VERSION = '1.17.0'
5
5
  end
@@ -35,6 +35,28 @@ RSpec.describe FastlyNsq do
35
35
  end
36
36
  end
37
37
 
38
+ describe '#logger' do
39
+ let!(:default_logger) { subject.logger }
40
+ after { subject.logger = default_logger }
41
+
42
+ it 'returns the set logger' do
43
+ logger = Logger.new(nil)
44
+ subject.logger = logger
45
+
46
+ expect(subject.logger).to eq logger
47
+ end
48
+
49
+ it 'sets the default logger if none is set' do
50
+ subject.instance_variable_set(:@logger, nil)
51
+ expect(subject.instance_variable_get(:@logger)).to be nil
52
+ logger = subject.logger
53
+
54
+ expect(logger).to be_instance_of(Logger)
55
+ expect(logger.instance_variable_get(:@logdev).dev).to eq(STDERR)
56
+ expect(logger).to eq(Nsq.logger)
57
+ end
58
+ end
59
+
38
60
  describe '#logger=' do
39
61
  let!(:default_logger) { subject.logger }
40
62
  after { subject.logger = default_logger }
@@ -45,6 +67,13 @@ RSpec.describe FastlyNsq do
45
67
 
46
68
  expect(subject.logger).to eq logger
47
69
  end
70
+
71
+ it 'sets Nsq.logger' do
72
+ logger = Logger.new(STDOUT)
73
+ subject.logger = logger
74
+
75
+ expect(Nsq.logger).to eq logger
76
+ end
48
77
  end
49
78
 
50
79
  describe '#manager' do
@@ -77,7 +106,8 @@ RSpec.describe FastlyNsq do
77
106
  it 'registers callbacks for events' do
78
107
  %i[startup shutdown heartbeat].each do |event|
79
108
  block = -> {}
80
- expect { FastlyNsq.on(event, &block) }.to change { FastlyNsq.events[event] }.by([block])
109
+ FastlyNsq.on(event, &block)
110
+ expect(FastlyNsq.events[event]).to eq([block])
81
111
  end
82
112
  end
83
113
 
data/spec/manager_spec.rb CHANGED
@@ -16,14 +16,14 @@ RSpec.describe FastlyNsq::Manager do
16
16
 
17
17
  describe '#initialize' do
18
18
  it 'allows max_threads to be specified' do
19
- max_threads = described_class::DEFAULT_POOL_SIZE * 2
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 'defaults max_threads to DEFAULT_POOL_SIZE' do
26
- expect(subject.pool.max_threads).to eq(described_class::DEFAULT_POOL_SIZE)
25
+ it 'defaults max_threads to FastlyNsq.max_processing_pool_threads' do
26
+ expect(subject.pool.max_threads).to eq(FastlyNsq.max_processing_pool_threads)
27
27
  end
28
28
 
29
29
  it 'allows fallback_policy to be specified' do
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: 1, finish: nil, requeue: nil, touch: nil, timestamp: nil }
7
+ let(:nsq_message) { double 'Nsq::Message', body: json_body, attempts: 1, finish: nil, requeue: nil, touch: nil, timestamp: nil, id: 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 }
@@ -30,7 +30,7 @@ RSpec.describe FastlyNsq::Message do
30
30
  end
31
31
 
32
32
  it 'delegates methods to the nsq_message object' do
33
- %w[attempts finish requeue touch timestamp].each do |method|
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)
36
36
 
@@ -72,6 +72,19 @@ RSpec.describe FastlyNsq::Messenger do
72
72
 
73
73
  expect(producer).to have_received(:write).with(expected_attributes.to_json)
74
74
  end
75
+
76
+ it 'can set the sent_at in the metadata' do
77
+ sent_at = Time.parse('2020-06-08 23:42:42')
78
+ meta = {}
79
+
80
+ expected_attributes = { data: message, meta: meta.merge(originating_service: origin, sent_at: sent_at.iso8601(5)) }
81
+
82
+ subject.producers['topic'] = producer
83
+
84
+ subject.deliver message: message, topic: 'topic', sent_at: sent_at, meta: meta, originating_service: origin
85
+
86
+ expect(producer).to have_received(:write).with(expected_attributes.to_json)
87
+ end
75
88
  end
76
89
 
77
90
  describe '#deliver_multi' do
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.13.0
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy O'Neil
@@ -10,10 +10,10 @@ authors:
10
10
  - Lukas Eklund
11
11
  - Josh Lane
12
12
  - Hassan Shahid
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2018-07-27 00:00:00.000000000 Z
16
+ date: 2021-02-16 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: awesome_print
@@ -33,16 +33,16 @@ dependencies:
33
33
  name: bundler
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - "~>"
36
+ - - ">="
37
37
  - !ruby/object:Gem::Version
38
- version: '1.12'
38
+ version: '0'
39
39
  type: :development
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  requirements:
43
- - - "~>"
43
+ - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: '1.12'
45
+ version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: dotenv
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -254,7 +254,7 @@ homepage: https://github.com/fastly/fastly_nsq
254
254
  licenses:
255
255
  - MIT
256
256
  metadata: {}
257
- post_install_message:
257
+ post_install_message:
258
258
  rdoc_options: []
259
259
  require_paths:
260
260
  - lib
@@ -269,9 +269,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
269
  - !ruby/object:Gem::Version
270
270
  version: '0'
271
271
  requirements: []
272
- rubyforge_project:
273
- rubygems_version: 2.7.3
274
- signing_key:
272
+ rubyforge_project:
273
+ rubygems_version: 2.7.9
274
+ signing_key:
275
275
  specification_version: 4
276
276
  summary: Fastly NSQ Adapter
277
277
  test_files: []