fastly_nsq 1.16.0 → 1.17.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7ddfaca7ffa4121e56b173447b114ccd61ea104bc3804f2833920438492f4da
4
- data.tar.gz: 570739450b84d445d190cb29b6d2ce7f22287bb4bde73f2af75e533eb00b2fc3
3
+ metadata.gz: 0a0de08856671c960970c164a3b95efdaef29bfb05ba2c8282cbc81d0e3d8282
4
+ data.tar.gz: bb52cbe4e13ca5bce686409eb20c7f13fd1975f41da73cc14a231a94d737a80c
5
5
  SHA512:
6
- metadata.gz: 9b9b61eb6bfb2cc6453f259887e4b045368fc87ab4d88f05ef1591c83c1a488d36bf555034990495221a92ef697933a9ed0d007f650f0f11ee8bf4357f0b826d
7
- data.tar.gz: 9e0202b599608733735097989d7f853b0e98def7299f366321509550ce9ea850ac23d757f81505bc2c7df1a73d3f742200b078733a9ba8036f6e96b175d7a4a5
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,23 @@
1
1
  # Change Log
2
2
 
3
- ## [v1.15.0](https://github.com/fastly/fastly_nsq/tree/v1.15.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)
5
21
  [Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.14.0...v1.15.0)
6
22
 
7
23
  **Merged pull requests:**
@@ -431,4 +447,4 @@
431
447
  ## [v0.0.1](https://github.com/fastly/fastly_nsq/tree/v0.0.1) (2016-01-30)
432
448
 
433
449
 
434
- \* *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
@@ -7,7 +7,7 @@ gemspec
7
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
@@ -334,3 +334,7 @@ You will still need the `ENV` variables as defined above.
334
334
  Copyright (c) 2016 [Fastly, Inc](https://fastly.com) under an MIT license.
335
335
 
336
336
  See [LICENSE.txt](LICENSE.txt) for details.
337
+
338
+ # Metadata
339
+
340
+ - Ignore
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastlyNsq
4
- VERSION = '1.16.0'
4
+ VERSION = '1.17.0'
5
5
  end
@@ -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.16.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: 2019-08-16 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
@@ -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:
272
+ rubyforge_project:
273
273
  rubygems_version: 2.7.9
274
- signing_key:
274
+ signing_key:
275
275
  specification_version: 4
276
276
  summary: Fastly NSQ Adapter
277
277
  test_files: []