fastly_nsq 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/ChangeLog.md +334 -15
- data/README.md +20 -4
- data/lib/fastly_nsq.rb +6 -1
- data/lib/fastly_nsq/consumer.rb +1 -1
- data/lib/fastly_nsq/messenger.rb +59 -7
- data/lib/fastly_nsq/producer.rb +42 -2
- data/lib/fastly_nsq/version.rb +1 -1
- data/spec/messenger_spec.rb +25 -0
- data/spec/producer_spec.rb +5 -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: 4e685ef385c44a03d16a119fab38034c03dbd9c9
|
4
|
+
data.tar.gz: da44d3e9ff527f75ef4fc2ee26b874f43a0c4fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11d5ce501f74bfafe9af2ff21e13cd8e6a7f03473370aac9663ea5989d6f9d5287a7d610e638397cbe10b880ff1b9e99a5bcc1dc6bf34bc28a32e4dce996e8a1
|
7
|
+
data.tar.gz: 54401d76b444e28470b69ff2dc3a11ec5c8f7e3b7090e6af5b779471757b714a9ca6b6cba47373a93d41160947c096ab539d4896db9c1d53990bf4242232779a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.1
|
data/.travis.yml
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,26 +1,345 @@
|
|
1
|
-
|
1
|
+
# Change Log
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
## [v1.8.0](https://github.com/fastly/fastly_nsq/tree/v1.8.0) (2018-05-30)
|
4
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.7.0...v1.8.0)
|
5
5
|
|
6
|
-
|
6
|
+
**Merged pull requests:**
|
7
7
|
|
8
|
-
|
8
|
+
- add lifecyle callbacks [\#77](https://github.com/fastly/fastly_nsq/pull/77) ([lanej](https://github.com/lanej))
|
9
|
+
- Add YARD-style documentation. [\#76](https://github.com/fastly/fastly_nsq/pull/76) ([leklund](https://github.com/leklund))
|
9
10
|
|
10
|
-
|
11
|
+
## [v1.7.0](https://github.com/fastly/fastly_nsq/tree/v1.7.0) (2018-04-26)
|
12
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.6.0...v1.7.0)
|
11
13
|
|
12
|
-
|
14
|
+
**Merged pull requests:**
|
13
15
|
|
14
|
-
|
16
|
+
- Add `sent\_at` to `meta` when `deliver` is called. [\#75](https://github.com/fastly/fastly_nsq/pull/75) ([set5think](https://github.com/set5think))
|
15
17
|
|
16
|
-
|
18
|
+
## [v1.6.0](https://github.com/fastly/fastly_nsq/tree/v1.6.0) (2018-04-17)
|
19
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.5.0...v1.6.0)
|
17
20
|
|
18
|
-
|
21
|
+
**Merged pull requests:**
|
19
22
|
|
20
|
-
|
21
|
-
* Support passing `verify_mode` in parameters and through ENV
|
22
|
-
* Change SSLContext class to be TlsOptions class to match gem needs
|
23
|
+
- add FastlyNsq::Testing.message [\#74](https://github.com/fastly/fastly_nsq/pull/74) ([lanej](https://github.com/lanej))
|
23
24
|
|
24
|
-
|
25
|
+
## [v1.5.0](https://github.com/fastly/fastly_nsq/tree/v1.5.0) (2018-04-16)
|
26
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.4.1...v1.5.0)
|
25
27
|
|
26
|
-
|
28
|
+
**Merged pull requests:**
|
29
|
+
|
30
|
+
- standardize logging format and add attempts [\#71](https://github.com/fastly/fastly_nsq/pull/71) ([lanej](https://github.com/lanej))
|
31
|
+
|
32
|
+
## [v1.4.1](https://github.com/fastly/fastly_nsq/tree/v1.4.1) (2018-04-12)
|
33
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.4.0...v1.4.1)
|
34
|
+
|
35
|
+
**Merged pull requests:**
|
36
|
+
|
37
|
+
- Cap the requeue\_period calculation at 30 attempts. [\#73](https://github.com/fastly/fastly_nsq/pull/73) ([leklund](https://github.com/leklund))
|
38
|
+
|
39
|
+
## [v1.4.0](https://github.com/fastly/fastly_nsq/tree/v1.4.0) (2018-04-12)
|
40
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.3.0...v1.4.0)
|
41
|
+
|
42
|
+
**Merged pull requests:**
|
43
|
+
|
44
|
+
- add exponential retries to FastlyNsq::Message [\#72](https://github.com/fastly/fastly_nsq/pull/72) ([leklund](https://github.com/leklund))
|
45
|
+
|
46
|
+
## [v1.3.0](https://github.com/fastly/fastly_nsq/tree/v1.3.0) (2018-04-11)
|
47
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.2.0...v1.3.0)
|
48
|
+
|
49
|
+
**Merged pull requests:**
|
50
|
+
|
51
|
+
- global max\_attempts setting [\#70](https://github.com/fastly/fastly_nsq/pull/70) ([lanej](https://github.com/lanej))
|
52
|
+
|
53
|
+
## [v1.2.0](https://github.com/fastly/fastly_nsq/tree/v1.2.0) (2018-04-11)
|
54
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.1.0...v1.2.0)
|
55
|
+
|
56
|
+
**Merged pull requests:**
|
57
|
+
|
58
|
+
- feature: allow specifications of consumer options via listener [\#69](https://github.com/fastly/fastly_nsq/pull/69) ([lanej](https://github.com/lanej))
|
59
|
+
|
60
|
+
## [v1.1.0](https://github.com/fastly/fastly_nsq/tree/v1.1.0) (2018-02-20)
|
61
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.0.2...v1.1.0)
|
62
|
+
|
63
|
+
**Merged pull requests:**
|
64
|
+
|
65
|
+
- upgrade nsq-ruby to ~\> 2.2 [\#68](https://github.com/fastly/fastly_nsq/pull/68) ([leklund](https://github.com/leklund))
|
66
|
+
|
67
|
+
## [v1.0.2](https://github.com/fastly/fastly_nsq/tree/v1.0.2) (2018-01-05)
|
68
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.0.1...v1.0.2)
|
69
|
+
|
70
|
+
**Merged pull requests:**
|
71
|
+
|
72
|
+
- fix: launcher heartbeat [\#67](https://github.com/fastly/fastly_nsq/pull/67) ([lanej](https://github.com/lanej))
|
73
|
+
|
74
|
+
## [v1.0.1](https://github.com/fastly/fastly_nsq/tree/v1.0.1) (2018-01-05)
|
75
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.0.0...v1.0.1)
|
76
|
+
|
77
|
+
**Merged pull requests:**
|
78
|
+
|
79
|
+
- fix: launcher correctly uses manager [\#66](https://github.com/fastly/fastly_nsq/pull/66) ([lanej](https://github.com/lanej))
|
80
|
+
|
81
|
+
## [v1.0.0](https://github.com/fastly/fastly_nsq/tree/v1.0.0) (2018-01-05)
|
82
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.13.2...v1.0.0)
|
83
|
+
|
84
|
+
**Closed issues:**
|
85
|
+
|
86
|
+
- We should use NSQ\_LOOKUPD to produce as well [\#28](https://github.com/fastly/fastly_nsq/issues/28)
|
87
|
+
|
88
|
+
**Merged pull requests:**
|
89
|
+
|
90
|
+
- Consumer read loops send work to a central, prioritized thread pool [\#65](https://github.com/fastly/fastly_nsq/pull/65) ([lanej](https://github.com/lanej))
|
91
|
+
|
92
|
+
## [v0.13.2](https://github.com/fastly/fastly_nsq/tree/v0.13.2) (2017-12-04)
|
93
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.13.0...v0.13.2)
|
94
|
+
|
95
|
+
**Merged pull requests:**
|
96
|
+
|
97
|
+
- Retrieve meta section of message [\#64](https://github.com/fastly/fastly_nsq/pull/64) ([set5think](https://github.com/set5think))
|
98
|
+
- Don't log the logger object when creating a listener. [\#63](https://github.com/fastly/fastly_nsq/pull/63) ([leklund](https://github.com/leklund))
|
99
|
+
- Set metadata [\#62](https://github.com/fastly/fastly_nsq/pull/62) ([set5think](https://github.com/set5think))
|
100
|
+
- To rubocop update [\#61](https://github.com/fastly/fastly_nsq/pull/61) ([alieander](https://github.com/alieander))
|
101
|
+
|
102
|
+
## [v0.13.0](https://github.com/fastly/fastly_nsq/tree/v0.13.0) (2017-11-29)
|
103
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.12.4...v0.13.0)
|
104
|
+
|
105
|
+
**Merged pull requests:**
|
106
|
+
|
107
|
+
- fix: store topic on produced mock message [\#60](https://github.com/fastly/fastly_nsq/pull/60) ([lanej](https://github.com/lanej))
|
108
|
+
- Implement Most Nsqd and Nsqlookupd Http api's [\#59](https://github.com/fastly/fastly_nsq/pull/59) ([alieander](https://github.com/alieander))
|
109
|
+
|
110
|
+
## [v0.12.4](https://github.com/fastly/fastly_nsq/tree/v0.12.4) (2017-11-02)
|
111
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.12.2...v0.12.4)
|
112
|
+
|
113
|
+
**Merged pull requests:**
|
114
|
+
|
115
|
+
- remove connection timeout on initialization [\#58](https://github.com/fastly/fastly_nsq/pull/58) ([alieander](https://github.com/alieander))
|
116
|
+
- Only raise if consumer is empty [\#57](https://github.com/fastly/fastly_nsq/pull/57) ([alieander](https://github.com/alieander))
|
117
|
+
|
118
|
+
## [v0.12.2](https://github.com/fastly/fastly_nsq/tree/v0.12.2) (2017-09-12)
|
119
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.12.1...v0.12.2)
|
120
|
+
|
121
|
+
**Merged pull requests:**
|
122
|
+
|
123
|
+
- terminate should also end the threads life... [\#56](https://github.com/fastly/fastly_nsq/pull/56) ([alieander](https://github.com/alieander))
|
124
|
+
|
125
|
+
## [v0.12.1](https://github.com/fastly/fastly_nsq/tree/v0.12.1) (2017-09-06)
|
126
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.12.0...v0.12.1)
|
127
|
+
|
128
|
+
**Merged pull requests:**
|
129
|
+
|
130
|
+
- Cleanup in the terminate and kill methods [\#55](https://github.com/fastly/fastly_nsq/pull/55) ([alieander](https://github.com/alieander))
|
131
|
+
|
132
|
+
## [v0.12.0](https://github.com/fastly/fastly_nsq/tree/v0.12.0) (2017-08-18)
|
133
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.10.1...v0.12.0)
|
134
|
+
|
135
|
+
**Merged pull requests:**
|
136
|
+
|
137
|
+
- This should load rails correctly. [\#54](https://github.com/fastly/fastly_nsq/pull/54) ([alieander](https://github.com/alieander))
|
138
|
+
- Add accessor for Nsq::Message object and delegate methods [\#53](https://github.com/fastly/fastly_nsq/pull/53) ([leklund](https://github.com/leklund))
|
139
|
+
- Cleanup / Warning removal [\#51](https://github.com/fastly/fastly_nsq/pull/51) ([alieander](https://github.com/alieander))
|
140
|
+
|
141
|
+
## [v0.10.1](https://github.com/fastly/fastly_nsq/tree/v0.10.1) (2017-07-14)
|
142
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.10.0...v0.10.1)
|
143
|
+
|
144
|
+
**Merged pull requests:**
|
145
|
+
|
146
|
+
- Add topic to listener log lines. [\#52](https://github.com/fastly/fastly_nsq/pull/52) ([leklund](https://github.com/leklund))
|
147
|
+
|
148
|
+
## [v0.10.0](https://github.com/fastly/fastly_nsq/tree/v0.10.0) (2017-06-09)
|
149
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.9.5...v0.10.0)
|
150
|
+
|
151
|
+
**Merged pull requests:**
|
152
|
+
|
153
|
+
- Setup a possible path to daemonize listeners [\#49](https://github.com/fastly/fastly_nsq/pull/49) ([alieander](https://github.com/alieander))
|
154
|
+
|
155
|
+
## [v0.9.5](https://github.com/fastly/fastly_nsq/tree/v0.9.5) (2017-05-25)
|
156
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.9.4...v0.9.5)
|
157
|
+
|
158
|
+
**Merged pull requests:**
|
159
|
+
|
160
|
+
- Consumer should connect on initialize [\#50](https://github.com/fastly/fastly_nsq/pull/50) ([leklund](https://github.com/leklund))
|
161
|
+
|
162
|
+
## [v0.9.4](https://github.com/fastly/fastly_nsq/tree/v0.9.4) (2017-04-13)
|
163
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.9.3...v0.9.4)
|
164
|
+
|
165
|
+
**Merged pull requests:**
|
166
|
+
|
167
|
+
- catch, log, and terminate to ensure producer dies [\#48](https://github.com/fastly/fastly_nsq/pull/48) ([alieander](https://github.com/alieander))
|
168
|
+
|
169
|
+
## [v0.9.3](https://github.com/fastly/fastly_nsq/tree/v0.9.3) (2017-01-19)
|
170
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.9.2...v0.9.3)
|
171
|
+
|
172
|
+
**Merged pull requests:**
|
173
|
+
|
174
|
+
- Wait for Producer to connect. [\#47](https://github.com/fastly/fastly_nsq/pull/47) ([alieander](https://github.com/alieander))
|
175
|
+
|
176
|
+
## [v0.9.2](https://github.com/fastly/fastly_nsq/tree/v0.9.2) (2017-01-17)
|
177
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.9.1...v0.9.2)
|
178
|
+
|
179
|
+
**Merged pull requests:**
|
180
|
+
|
181
|
+
- bump version to 0.9.2 [\#46](https://github.com/fastly/fastly_nsq/pull/46) ([alieander](https://github.com/alieander))
|
182
|
+
- we should produce to a lookup as well [\#45](https://github.com/fastly/fastly_nsq/pull/45) ([alieander](https://github.com/alieander))
|
183
|
+
|
184
|
+
## [v0.9.1](https://github.com/fastly/fastly_nsq/tree/v0.9.1) (2017-01-04)
|
185
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.9.0...v0.9.1)
|
186
|
+
|
187
|
+
**Merged pull requests:**
|
188
|
+
|
189
|
+
- update nsq-ruby dependency [\#44](https://github.com/fastly/fastly_nsq/pull/44) ([leklund](https://github.com/leklund))
|
190
|
+
|
191
|
+
## [v0.9.0](https://github.com/fastly/fastly_nsq/tree/v0.9.0) (2016-12-20)
|
192
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.8.0...v0.9.0)
|
193
|
+
|
194
|
+
**Merged pull requests:**
|
195
|
+
|
196
|
+
- Reuse connections [\#43](https://github.com/fastly/fastly_nsq/pull/43) ([leklund](https://github.com/leklund))
|
197
|
+
|
198
|
+
## [v0.8.0](https://github.com/fastly/fastly_nsq/tree/v0.8.0) (2016-11-29)
|
199
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.7.1...v0.8.0)
|
200
|
+
|
201
|
+
**Merged pull requests:**
|
202
|
+
|
203
|
+
- Upgrade to nsq-ruby version 2.0.3 [\#42](https://github.com/fastly/fastly_nsq/pull/42) ([alieander](https://github.com/alieander))
|
204
|
+
|
205
|
+
## [v0.7.1](https://github.com/fastly/fastly_nsq/tree/v0.7.1) (2016-10-26)
|
206
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.7.0...v0.7.1)
|
207
|
+
|
208
|
+
**Merged pull requests:**
|
209
|
+
|
210
|
+
- Allow the use of multiple lookups [\#40](https://github.com/fastly/fastly_nsq/pull/40) ([alieander](https://github.com/alieander))
|
211
|
+
|
212
|
+
## [v0.7.0](https://github.com/fastly/fastly_nsq/tree/v0.7.0) (2016-08-10)
|
213
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.6.0...v0.7.0)
|
214
|
+
|
215
|
+
**Closed issues:**
|
216
|
+
|
217
|
+
- \[RFC\] Use JSON schemata to validate messages before publishing [\#31](https://github.com/fastly/fastly_nsq/issues/31)
|
218
|
+
|
219
|
+
**Merged pull requests:**
|
220
|
+
|
221
|
+
- Colons help the world go ... [\#39](https://github.com/fastly/fastly_nsq/pull/39) ([alieander](https://github.com/alieander))
|
222
|
+
- call Thread\#join only on threads we created [\#38](https://github.com/fastly/fastly_nsq/pull/38) ([alieander](https://github.com/alieander))
|
223
|
+
- Consistent use of namespace & injectable dependencies [\#37](https://github.com/fastly/fastly_nsq/pull/37) ([jaw6](https://github.com/jaw6))
|
224
|
+
- Remove broadcast Address [\#36](https://github.com/fastly/fastly_nsq/pull/36) ([alieander](https://github.com/alieander))
|
225
|
+
- Update PR template to warn against Jira URLs [\#35](https://github.com/fastly/fastly_nsq/pull/35) ([adarsh](https://github.com/adarsh))
|
226
|
+
- Update TravisCI \> Slack integration key [\#34](https://github.com/fastly/fastly_nsq/pull/34) ([adarsh](https://github.com/adarsh))
|
227
|
+
|
228
|
+
## [v0.6.0](https://github.com/fastly/fastly_nsq/tree/v0.6.0) (2016-05-13)
|
229
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.5.1...v0.6.0)
|
230
|
+
|
231
|
+
**Merged pull requests:**
|
232
|
+
|
233
|
+
- Producer\#connection -\> Producer [\#29](https://github.com/fastly/fastly_nsq/pull/29) ([jaw6](https://github.com/jaw6))
|
234
|
+
|
235
|
+
## [v0.5.1](https://github.com/fastly/fastly_nsq/tree/v0.5.1) (2016-05-12)
|
236
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.5.0...v0.5.1)
|
237
|
+
|
238
|
+
**Closed issues:**
|
239
|
+
|
240
|
+
- Listener spec seems todo nothing. [\#27](https://github.com/fastly/fastly_nsq/issues/27)
|
241
|
+
|
242
|
+
**Merged pull requests:**
|
243
|
+
|
244
|
+
- Persist connection [\#32](https://github.com/fastly/fastly_nsq/pull/32) ([jaw6](https://github.com/jaw6))
|
245
|
+
- Remove unnecessary listener spec [\#30](https://github.com/fastly/fastly_nsq/pull/30) ([adarsh](https://github.com/adarsh))
|
246
|
+
|
247
|
+
## [v0.5.0](https://github.com/fastly/fastly_nsq/tree/v0.5.0) (2016-05-10)
|
248
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.4.0...v0.5.0)
|
249
|
+
|
250
|
+
**Merged pull requests:**
|
251
|
+
|
252
|
+
- Should Listener\#consumer -\> Consumer, or Consumer\#connection? [\#26](https://github.com/fastly/fastly_nsq/pull/26) ([jaw6](https://github.com/jaw6))
|
253
|
+
|
254
|
+
## [v0.4.0](https://github.com/fastly/fastly_nsq/tree/v0.4.0) (2016-04-21)
|
255
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.3.1...v0.4.0)
|
256
|
+
|
257
|
+
**Merged pull requests:**
|
258
|
+
|
259
|
+
- Add SSLContext to fastly\_nsq [\#25](https://github.com/fastly/fastly_nsq/pull/25) ([alieander](https://github.com/alieander))
|
260
|
+
|
261
|
+
## [v0.3.1](https://github.com/fastly/fastly_nsq/tree/v0.3.1) (2016-03-29)
|
262
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.3.0...v0.3.1)
|
263
|
+
|
264
|
+
**Merged pull requests:**
|
265
|
+
|
266
|
+
- Update rake to 11.1.2 [\#24](https://github.com/fastly/fastly_nsq/pull/24) ([adarsh](https://github.com/adarsh))
|
267
|
+
- Add Rubocop and Overcommit [\#23](https://github.com/fastly/fastly_nsq/pull/23) ([adarsh](https://github.com/adarsh))
|
268
|
+
|
269
|
+
## [v0.3.0](https://github.com/fastly/fastly_nsq/tree/v0.3.0) (2016-03-17)
|
270
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.2.3...v0.3.0)
|
271
|
+
|
272
|
+
**Merged pull requests:**
|
273
|
+
|
274
|
+
- Listen to multiple queues at once [\#22](https://github.com/fastly/fastly_nsq/pull/22) ([adarsh](https://github.com/adarsh))
|
275
|
+
|
276
|
+
## [v0.2.3](https://github.com/fastly/fastly_nsq/tree/v0.2.3) (2016-03-11)
|
277
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.2.2...v0.2.3)
|
278
|
+
|
279
|
+
**Merged pull requests:**
|
280
|
+
|
281
|
+
- Add a PULL\_REQUEST\_TEMPLATE.md [\#20](https://github.com/fastly/fastly_nsq/pull/20) ([alieander](https://github.com/alieander))
|
282
|
+
- Cleanup rake\_task tests; Extend examples [\#19](https://github.com/fastly/fastly_nsq/pull/19) ([alieander](https://github.com/alieander))
|
283
|
+
- Allow a logger to be defined on underlying nsq gem [\#16](https://github.com/fastly/fastly_nsq/pull/16) ([alieander](https://github.com/alieander))
|
284
|
+
|
285
|
+
## [v0.2.2](https://github.com/fastly/fastly_nsq/tree/v0.2.2) (2016-03-10)
|
286
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.2.1...v0.2.2)
|
287
|
+
|
288
|
+
**Fixed bugs:**
|
289
|
+
|
290
|
+
- Have the fake consumer block on an empty queue [\#13](https://github.com/fastly/fastly_nsq/pull/13) ([adarsh](https://github.com/adarsh))
|
291
|
+
|
292
|
+
**Merged pull requests:**
|
293
|
+
|
294
|
+
- Add RSpec fake\_queue: true|false flags [\#17](https://github.com/fastly/fastly_nsq/pull/17) ([adarsh](https://github.com/adarsh))
|
295
|
+
- Bump to 0.2.2 [\#14](https://github.com/fastly/fastly_nsq/pull/14) ([adarsh](https://github.com/adarsh))
|
296
|
+
- Raise custom exeception for empty fake queue [\#12](https://github.com/fastly/fastly_nsq/pull/12) ([adarsh](https://github.com/adarsh))
|
297
|
+
|
298
|
+
## [v0.2.1](https://github.com/fastly/fastly_nsq/tree/v0.2.1) (2016-02-26)
|
299
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.2.0...v0.2.1)
|
300
|
+
|
301
|
+
**Merged pull requests:**
|
302
|
+
|
303
|
+
- Bump version to 0.2.1 [\#11](https://github.com/fastly/fastly_nsq/pull/11) ([adarsh](https://github.com/adarsh))
|
304
|
+
- Implement termination of the fake connections [\#10](https://github.com/fastly/fastly_nsq/pull/10) ([adarsh](https://github.com/adarsh))
|
305
|
+
|
306
|
+
## [v0.2.0](https://github.com/fastly/fastly_nsq/tree/v0.2.0) (2016-02-26)
|
307
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.1.4...v0.2.0)
|
308
|
+
|
309
|
+
**Merged pull requests:**
|
310
|
+
|
311
|
+
- Use RSpec [\#9](https://github.com/fastly/fastly_nsq/pull/9) ([adarsh](https://github.com/adarsh))
|
312
|
+
- Terminate producer and consumer connections [\#8](https://github.com/fastly/fastly_nsq/pull/8) ([adarsh](https://github.com/adarsh))
|
313
|
+
- Fix test errors [\#7](https://github.com/fastly/fastly_nsq/pull/7) ([adarsh](https://github.com/adarsh))
|
314
|
+
- To add listener rake task [\#6](https://github.com/fastly/fastly_nsq/pull/6) ([alieander](https://github.com/alieander))
|
315
|
+
|
316
|
+
## [v0.1.4](https://github.com/fastly/fastly_nsq/tree/v0.1.4) (2016-02-11)
|
317
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.1.3...v0.1.4)
|
318
|
+
|
319
|
+
**Merged pull requests:**
|
320
|
+
|
321
|
+
- Bump version to 0.1.4 [\#5](https://github.com/fastly/fastly_nsq/pull/5) ([adarsh](https://github.com/adarsh))
|
322
|
+
- Initialize the fake queue with an empty array [\#4](https://github.com/fastly/fastly_nsq/pull/4) ([adarsh](https://github.com/adarsh))
|
323
|
+
|
324
|
+
## [v0.1.3](https://github.com/fastly/fastly_nsq/tree/v0.1.3) (2016-02-03)
|
325
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.1.1...v0.1.3)
|
326
|
+
|
327
|
+
**Merged pull requests:**
|
328
|
+
|
329
|
+
- Use a more canonical way to require files [\#3](https://github.com/fastly/fastly_nsq/pull/3) ([adarsh](https://github.com/adarsh))
|
330
|
+
- Remove dependancy on ActiveSupport [\#2](https://github.com/fastly/fastly_nsq/pull/2) ([adarsh](https://github.com/adarsh))
|
331
|
+
|
332
|
+
## [v0.1.1](https://github.com/fastly/fastly_nsq/tree/v0.1.1) (2016-02-03)
|
333
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.0.2...v0.1.1)
|
334
|
+
|
335
|
+
## [v0.0.2](https://github.com/fastly/fastly_nsq/tree/v0.0.2) (2016-02-03)
|
336
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v0.0.1...v0.0.2)
|
337
|
+
|
338
|
+
**Merged pull requests:**
|
339
|
+
|
340
|
+
- Refactor to move up Producer/Consumer classes [\#1](https://github.com/fastly/fastly_nsq/pull/1) ([adarsh](https://github.com/adarsh))
|
341
|
+
|
342
|
+
## [v0.0.1](https://github.com/fastly/fastly_nsq/tree/v0.0.1) (2016-01-30)
|
343
|
+
|
344
|
+
|
345
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# fastly_nsq [![Build Status](https://travis-ci.org/fastly/fastly_nsq.svg?branch=master)](https://travis-ci.org/fastly/fastly_nsq)
|
2
2
|
|
3
|
-
*NOTE: This is a point-release
|
4
|
-
which is not yet suitable for production.
|
5
|
-
Use at your own peril.*
|
6
|
-
|
7
3
|
NSQ adapter and testing objects
|
8
4
|
for using the NSQ messaging system
|
9
5
|
in your Ruby project.
|
@@ -196,6 +192,13 @@ You can also set the originating service for all `deliver` calls:
|
|
196
192
|
FastlyNsq::Messenger.originating_service = 'some awesome service'
|
197
193
|
```
|
198
194
|
|
195
|
+
`FastlyNsq::Messenger` also spuports delivering multiple message at once and will
|
196
|
+
use the NSQ `mpub` directive under the hood.
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
FastlyNsq::Messenger.deliver_multi(messages: array_of_msgs, topic: 'my_topic')
|
200
|
+
```
|
201
|
+
|
199
202
|
`FastlyNsq::Messenger` can also be used to manage Producer connections
|
200
203
|
|
201
204
|
```ruby
|
@@ -295,6 +298,19 @@ NSQLOOKUPD_HTTP_ADDRESS='127.0.0.1:4161, 10.1.1.101:4161'
|
|
295
298
|
See the [`.sample.env`](examples/.sample.env) file
|
296
299
|
for more detail.
|
297
300
|
|
301
|
+
## Development
|
302
|
+
|
303
|
+
The fastest way to get up and running for development is to use
|
304
|
+
the Docker container provided by Docker Compose:
|
305
|
+
|
306
|
+
* Clone: `git clone https://github.com/fastly/fastly_nsq.git`
|
307
|
+
* `cd fastly_nsq`
|
308
|
+
* run `bundle install`
|
309
|
+
* run `docker-compose up -d`
|
310
|
+
* `rake spec`
|
311
|
+
|
312
|
+
You will still need the `ENV` variables as defined above.
|
313
|
+
|
298
314
|
## Contributors
|
299
315
|
|
300
316
|
* Adarsh Pandit ([@adarsh](https://github.com/adarsh))
|
data/lib/fastly_nsq.rb
CHANGED
@@ -95,19 +95,24 @@ module FastlyNsq
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# Register a block to run at a point in the lifecycle.
|
98
|
-
# :startup, :heartbeat or :shutdown are valid events.
|
99
98
|
#
|
99
|
+
# @example
|
100
100
|
# FastlyNsq.configure do |config|
|
101
101
|
# config.on(:shutdown) do
|
102
102
|
# puts "Goodbye cruel world!"
|
103
103
|
# end
|
104
104
|
# end
|
105
|
+
# @param event [Symbol] Event to hook into. One of :startup, :heartbeat or :shutdown.
|
106
|
+
# @yield Proc to execute when event is triggered.
|
105
107
|
def on(event, &block)
|
106
108
|
event = event.to_sym
|
107
109
|
raise ArgumentError, "Invalid event name: #{event}" unless LIFECYCLE_EVENTS.include?(event)
|
108
110
|
events[event] << block
|
109
111
|
end
|
110
112
|
|
113
|
+
# Execute Procs assigned for the lifecycle event
|
114
|
+
#
|
115
|
+
# @param event [Symbol] Lifecycle event to trigger
|
111
116
|
def fire_event(event)
|
112
117
|
blocks = FastlyNsq.events.fetch(event)
|
113
118
|
blocks.each do |block|
|
data/lib/fastly_nsq/consumer.rb
CHANGED
@@ -55,7 +55,7 @@ class FastlyNsq::Consumer
|
|
55
55
|
# @!method terminate
|
56
56
|
# Delegated to +self.connection+
|
57
57
|
# @return [Nsq::Consumer#terminate]
|
58
|
-
# @see https://www.rubydoc.info/gems/nsq-ruby/Nsq%
|
58
|
+
# @see https://www.rubydoc.info/gems/nsq-ruby/Nsq%2FClientBase:terminate Nsq::ClientBase#terminate
|
59
59
|
def_delegators :connection, :connected?, :pop, :pop_without_blocking, :size, :terminate
|
60
60
|
|
61
61
|
##
|
data/lib/fastly_nsq/messenger.rb
CHANGED
@@ -16,22 +16,62 @@ module FastlyNsq::Messenger
|
|
16
16
|
module_function
|
17
17
|
|
18
18
|
##
|
19
|
-
# Deliver an NSQ message
|
20
|
-
#
|
19
|
+
# Deliver an NSQ message. Uses +pub+
|
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.
|
24
|
+
# @param message [#to_json(*)] written to the +data+ key of the NSQ message payload
|
21
25
|
# @param topic [String] NSQ topic on which to deliver the message
|
22
26
|
# @param originating_service [String] added to meta key of message payload
|
23
27
|
# @param meta [Hash]
|
24
28
|
# @return [Void]
|
29
|
+
# @example
|
30
|
+
# FastlyNsq::Messenger.deliver(
|
31
|
+
# message: {a: 1, count: 123},
|
32
|
+
# topic: 'count',
|
33
|
+
# )
|
25
34
|
def deliver(message:, topic:, originating_service: nil, meta: {})
|
26
|
-
meta[:originating_service] = originating_service || self.originating_service
|
27
|
-
meta[:sent_at] = Time.now.iso8601(5)
|
28
|
-
|
29
35
|
payload = {
|
30
36
|
data: message,
|
31
|
-
meta: meta,
|
37
|
+
meta: populate_meta(originating_service: originating_service, meta: meta),
|
32
38
|
}
|
33
39
|
|
34
|
-
|
40
|
+
deliver_payload(topic: topic, payload: payload.to_json)
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Deliver many NSQ messages at once. Uses +mpub+
|
45
|
+
#
|
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.
|
50
|
+
# The +sent_at+ time and +originating_service+ will be the same for every message.
|
51
|
+
# @param messages [Array] Array of message which will be written to +data+ key of the
|
52
|
+
# individual NSQ message payload. Each message needs to respond to +to_json(*)+.
|
53
|
+
# @param topic [String] NSQ topic on which to deliver the message
|
54
|
+
# @param originating_service [String] added to meta key of message payload
|
55
|
+
# @param meta [Hash]
|
56
|
+
# @return [Void]
|
57
|
+
# @example
|
58
|
+
# FastlyNsq::Messenger.deliver_multi(
|
59
|
+
# messages: [{a: 1, count: 11}, {a: 2, count: 22}],
|
60
|
+
# topic: 'counts',
|
61
|
+
# )
|
62
|
+
def deliver_multi(messages:, topic:, originating_service: nil, meta: {})
|
63
|
+
meta = populate_meta(originating_service: originating_service, meta: meta)
|
64
|
+
|
65
|
+
payload = messages.each_with_object([]) do |message, a|
|
66
|
+
msg = {
|
67
|
+
data: message,
|
68
|
+
meta: meta,
|
69
|
+
}
|
70
|
+
|
71
|
+
a << msg.to_json
|
72
|
+
end
|
73
|
+
|
74
|
+
deliver_payload(topic: topic, payload: payload)
|
35
75
|
end
|
36
76
|
|
37
77
|
def originating_service=(service)
|
@@ -74,4 +114,16 @@ module FastlyNsq::Messenger
|
|
74
114
|
def originating_service
|
75
115
|
@originating_service || DEFAULT_ORIGIN
|
76
116
|
end
|
117
|
+
|
118
|
+
private_class_method
|
119
|
+
|
120
|
+
def deliver_payload(topic:, payload:)
|
121
|
+
producer_for(topic: topic) { |producer| producer.write payload }
|
122
|
+
end
|
123
|
+
|
124
|
+
def populate_meta(originating_service: nil, meta: {})
|
125
|
+
meta[:originating_service] = originating_service || self.originating_service
|
126
|
+
meta[:sent_at] = Time.now.iso8601(5)
|
127
|
+
meta
|
128
|
+
end
|
77
129
|
end
|
data/lib/fastly_nsq/producer.rb
CHANGED
@@ -1,10 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Provides an adapter to an Nsq::Producer
|
4
|
+
# and used to write messages to the queue.
|
5
|
+
#
|
6
|
+
# @example
|
7
|
+
# producer = FastlyNsq::Producer.new(topic: 'topic)
|
8
|
+
# producer.write('my message')
|
3
9
|
class FastlyNsq::Producer
|
4
10
|
DEFAULT_CONNECTION_TIMEOUT = 5 # seconds
|
5
11
|
|
6
|
-
|
12
|
+
# @return [String] NSQ Topic
|
13
|
+
attr_reader :topic
|
7
14
|
|
15
|
+
# @return [Nsq::Producer]
|
16
|
+
attr_reader :connection
|
17
|
+
|
18
|
+
# @return [Integer] connection timeout in seconds
|
19
|
+
attr_reader :connect_timeout
|
20
|
+
|
21
|
+
# @return [Logger]
|
22
|
+
attr_reader :logger
|
23
|
+
|
24
|
+
##
|
25
|
+
# Create a FastlyNsq::Producer
|
26
|
+
#
|
27
|
+
# @param topic [String] NSQ topic on which to deliver the message
|
28
|
+
# @param tls_options [Hash] Hash of TSL options passed the connection.
|
29
|
+
# In most cases this should be nil unless you need to override the
|
30
|
+
# default values set in ENV.
|
31
|
+
# @param logger [Logger] defaults to FastlyNsq.logger
|
32
|
+
# @param connect_timeout [Integer] NSQ connection timeout in seconds
|
8
33
|
def initialize(topic:, tls_options: nil, logger: FastlyNsq.logger, connect_timeout: DEFAULT_CONNECTION_TIMEOUT)
|
9
34
|
@topic = topic
|
10
35
|
@tls_options = FastlyNsq::TlsOptions.as_hash(tls_options)
|
@@ -14,22 +39,37 @@ class FastlyNsq::Producer
|
|
14
39
|
connect
|
15
40
|
end
|
16
41
|
|
42
|
+
##
|
43
|
+
# Terminate the NSQ connection and set connection instance to +nil+
|
44
|
+
# @return [Nsq::Producer#terminate]
|
45
|
+
# @see https://www.rubydoc.info/gems/nsq-ruby/Nsq%2FClientBase:terminate Nsq::ClientBase#terminate
|
17
46
|
def terminate
|
18
47
|
connection.terminate
|
19
48
|
@connection = nil
|
20
49
|
end
|
21
50
|
|
51
|
+
##
|
52
|
+
# Check conenction status
|
53
|
+
# @return [Nsq::Consumer#connected?]
|
54
|
+
# @see https://www.rubydoc.info/gems/nsq-ruby/Nsq/ClientBase#connected%3F-instance_method Nsq::ClientBase#connected?
|
22
55
|
def connected?
|
23
56
|
return false unless connection
|
24
57
|
|
25
58
|
connection.connected?
|
26
59
|
end
|
27
60
|
|
61
|
+
##
|
62
|
+
# Write a message
|
63
|
+
# @return [Nsq::Producer#pop]
|
64
|
+
# @see https://www.rubydoc.info/gems/nsq-ruby/Nsq%2FProducer:write Nsq::Producer#write
|
28
65
|
def write(message)
|
29
66
|
raise FastlyNsq::NotConnectedError unless connected?
|
30
|
-
connection.write
|
67
|
+
connection.write(*message)
|
31
68
|
end
|
32
69
|
|
70
|
+
##
|
71
|
+
# Create an Nsq::Producer and set as +@connection+ instance variable
|
72
|
+
# @return [Boolean]
|
33
73
|
def connect
|
34
74
|
lookupd = FastlyNsq.lookupd_http_addresses
|
35
75
|
|
data/lib/fastly_nsq/version.rb
CHANGED
data/spec/messenger_spec.rb
CHANGED
@@ -6,6 +6,7 @@ require 'json'
|
|
6
6
|
|
7
7
|
RSpec.describe FastlyNsq::Messenger do
|
8
8
|
let(:message) { { sample: 'sample', message: 'message' } }
|
9
|
+
let(:message2) { { sample: 'elpmas', message: 'egassem' } }
|
9
10
|
let(:producer) { double 'FastlyNsq::Producer', write: nil, terminate: :terminated }
|
10
11
|
let(:origin) { 'originating_service' }
|
11
12
|
let(:sent_at) { Time.now.iso8601(5) }
|
@@ -73,6 +74,30 @@ RSpec.describe FastlyNsq::Messenger do
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
77
|
+
describe '#deliver_multi' do
|
78
|
+
let(:expected_attributes_multi) do
|
79
|
+
[
|
80
|
+
expected_attributes.to_json,
|
81
|
+
{
|
82
|
+
data: message2,
|
83
|
+
meta: {
|
84
|
+
originating_service: 'originating_service',
|
85
|
+
sent_at: sent_at,
|
86
|
+
},
|
87
|
+
}.to_json,
|
88
|
+
]
|
89
|
+
end
|
90
|
+
before { Timecop.freeze(sent_at) }
|
91
|
+
|
92
|
+
it 'writes an array of messages on a producer' do
|
93
|
+
subject.producers['topic'] = producer
|
94
|
+
|
95
|
+
subject.deliver_multi messages: [message, message2], topic: 'topic', originating_service: origin
|
96
|
+
|
97
|
+
expect(producer).to have_received(:write).with(expected_attributes_multi)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
76
101
|
describe '#originating_service=' do
|
77
102
|
before { Timecop.freeze(sent_at) }
|
78
103
|
|
data/spec/producer_spec.rb
CHANGED
@@ -17,6 +17,11 @@ RSpec.describe FastlyNsq::Producer do
|
|
17
17
|
expect { message_count(topic) }.to eventually(eq(1)).within(5)
|
18
18
|
end
|
19
19
|
|
20
|
+
it 'writes multiple messages' do
|
21
|
+
subject.write %w[foo bar]
|
22
|
+
expect { message_count(topic) }.to eventually(eq(2)).within(5)
|
23
|
+
end
|
24
|
+
|
20
25
|
it 'should terminate' do
|
21
26
|
expect { subject.terminate }.to change(subject, :connected?).to(false)
|
22
27
|
expect(subject.connection).to eq(nil)
|
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.
|
4
|
+
version: 1.9.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-
|
16
|
+
date: 2018-06-04 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: awesome_print
|