hutch 0.19.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.travis.yml +11 -0
  4. data/CHANGELOG.md +438 -0
  5. data/Gemfile +22 -0
  6. data/Guardfile +5 -0
  7. data/LICENSE +22 -0
  8. data/README.md +317 -0
  9. data/Rakefile +14 -0
  10. data/bin/hutch +8 -0
  11. data/circle.yml +3 -0
  12. data/examples/consumer.rb +13 -0
  13. data/examples/producer.rb +10 -0
  14. data/hutch.gemspec +30 -0
  15. data/lib/hutch.rb +62 -0
  16. data/lib/hutch/adapter.rb +11 -0
  17. data/lib/hutch/adapters/bunny.rb +33 -0
  18. data/lib/hutch/adapters/march_hare.rb +37 -0
  19. data/lib/hutch/broker.rb +374 -0
  20. data/lib/hutch/cli.rb +205 -0
  21. data/lib/hutch/config.rb +125 -0
  22. data/lib/hutch/consumer.rb +75 -0
  23. data/lib/hutch/error_handlers.rb +8 -0
  24. data/lib/hutch/error_handlers/airbrake.rb +26 -0
  25. data/lib/hutch/error_handlers/honeybadger.rb +28 -0
  26. data/lib/hutch/error_handlers/logger.rb +16 -0
  27. data/lib/hutch/error_handlers/sentry.rb +23 -0
  28. data/lib/hutch/exceptions.rb +7 -0
  29. data/lib/hutch/logging.rb +32 -0
  30. data/lib/hutch/message.rb +31 -0
  31. data/lib/hutch/serializers/identity.rb +19 -0
  32. data/lib/hutch/serializers/json.rb +22 -0
  33. data/lib/hutch/tracers.rb +6 -0
  34. data/lib/hutch/tracers/newrelic.rb +19 -0
  35. data/lib/hutch/tracers/null_tracer.rb +15 -0
  36. data/lib/hutch/version.rb +4 -0
  37. data/lib/hutch/worker.rb +143 -0
  38. data/spec/hutch/broker_spec.rb +377 -0
  39. data/spec/hutch/cli_spec.rb +80 -0
  40. data/spec/hutch/config_spec.rb +126 -0
  41. data/spec/hutch/consumer_spec.rb +130 -0
  42. data/spec/hutch/error_handlers/airbrake_spec.rb +34 -0
  43. data/spec/hutch/error_handlers/honeybadger_spec.rb +36 -0
  44. data/spec/hutch/error_handlers/logger_spec.rb +15 -0
  45. data/spec/hutch/error_handlers/sentry_spec.rb +20 -0
  46. data/spec/hutch/logger_spec.rb +28 -0
  47. data/spec/hutch/message_spec.rb +38 -0
  48. data/spec/hutch/serializers/json_spec.rb +17 -0
  49. data/spec/hutch/worker_spec.rb +99 -0
  50. data/spec/hutch_spec.rb +87 -0
  51. data/spec/spec_helper.rb +40 -0
  52. metadata +194 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3780a985cc41fd9bb1d5f1a9bf09c66ff5eeacc8
4
+ data.tar.gz: 2c39b6799d48cfcc22e9ba30d02adb5c0ffe3347
5
+ SHA512:
6
+ metadata.gz: eedfd7d489f9eed88c3dccb2b4c2e68923addd22e694cfccb6d0af5051fd965b288f5075dded20f487e209a93072e4f1ec15cd44e85f1c3313800e299ec0d88d
7
+ data.tar.gz: 00b14523051465133e369643ebe4d4f0e2d028532afca8650143fe3a63b46ef0862960235cd4191816d609ef104f458a4a09229c805c9ba3aa96cd03d3b2e5ff
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .bundle
2
+ hutch-*.gem
3
+ Gemfile.lock
4
+ .ruby-version
5
+ .ruby-gemset
6
+ .idea
7
+ coverage
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.2"
4
+ - "2.1"
5
+ - "2.0"
6
+ - "jruby-9.0.0.0"
7
+ services:
8
+ - rabbitmq
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: jruby-9.0.0.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,438 @@
1
+ ## 0.19.0 — (unreleased)
2
+
3
+ ### Pluggable Serialisers
4
+
5
+ Hutch now supports pluggable serialisers: see `Hutch::Serializer::JSON` for
6
+ an example. Serialiser is configured via Hutch config as a Ruby
7
+ class.
8
+
9
+ Contributed by Dmitry Galinsky.
10
+
11
+
12
+ ### multi_json Update
13
+
14
+ Hutch now depends on multi_json `1.11.x`.
15
+
16
+ ### Bunny Update
17
+
18
+ Bunny is updated to [2.2.0](http://blog.rubyrabbitmq.info/blog/2015/09/06/bunny-2-dot-2-0-is-released/).
19
+
20
+ ### More Bunny SSL Options
21
+
22
+ `:mq_tls_ca_certificates` and `:mq_verify_peer` options will now be passed on to Bunny as `:tls_ca_certificates` and `:verify_peer` respectively.
23
+
24
+ Contributed by Kennon Ballou.
25
+
26
+ ## 0.18.0 — August 16th, 2015
27
+
28
+ ### JRuby Support (Using March Hare)
29
+
30
+ Hutch will now use March Hare when running on JRuby.
31
+ This will yield significant throughput and core utilisation
32
+ improvements for workloads with many and/or busy consumers.
33
+
34
+ Contributed by Teodor Pripoae.
35
+
36
+
37
+ ### Configurable Consumer Thread Pool Size
38
+
39
+ `:consumer_pool_size` is a new option (defaults to `1`) which defines
40
+ Bunny consumer work pool size.
41
+
42
+ Contributed by Derek Kastner.
43
+
44
+ ### Bunny Logger Option
45
+
46
+ `:client_logger` is a new option that allows
47
+ for configuring loggerd used by Bunny, the underlying
48
+ RabbitMQ client library.
49
+
50
+ Contributed by Nate Salisbury.
51
+
52
+
53
+ ## 0.17.0 — July 19th, 2015
54
+
55
+ Fixes an issue with `NoMethodError` in `Hutch::Config`.
56
+
57
+
58
+ ## 0.16.0 — July 19th, 2015
59
+
60
+ ### Support amqps URIs
61
+
62
+ Hutch now automatically enables TLS and changes default port
63
+ when URI scheme is `amqps`.
64
+
65
+ Contributed by Carl Hörberg.
66
+
67
+ ### Hash With Indifferent Access
68
+
69
+ Hutch now uses `HashWithIndifferentAccess` internally
70
+ to reduce use of symbols (which are not garbage collected
71
+ by widely used Ruby versions).
72
+
73
+ Contributed by Teodor Pripoae.
74
+
75
+
76
+ ## 0.15.0 — May 5th, 2015
77
+
78
+ ### Airbrake Error Handler
79
+
80
+ Contributed by Nate Salisbury.
81
+
82
+ ### Ruby 1.9 Support Dropped
83
+
84
+ Ruby 1.9 is no longer supported by Hutch (and soon Bunny 2.0).
85
+ 1.9 is also no longer maintained by the Ruby core team.
86
+
87
+ ### Custom Arguments per Consumers
88
+
89
+ Allow to set custom arguments per consumers by using the `arguments` setter.
90
+ Arguments are usually used by rabbitmq plugins or to set queue policies. You can
91
+ find a list of supported arguments [here](https://www.rabbitmq.com/extensions.html).
92
+
93
+ Contributed by Pierre-Louis Gottfrois.
94
+
95
+ ### Message Processing Tracers
96
+
97
+ Allow to track message processing by using the `:tracer` config option,
98
+ the value should be a class (or fully-qualified string name of a class) that
99
+ implements the tracing interface.
100
+
101
+ A tracer that performs NewRelic instrumentation ships with Hutch
102
+ and requires New Relic gem to be loaded.
103
+
104
+ Contributed by Mirosław Nagaś.
105
+
106
+ ### Added Logger Method to Consumer Module
107
+
108
+ Consumers can now call a logger method to write to Hutch's log.
109
+
110
+ Contributed by Matty Courtney
111
+
112
+ ## 0.14.0 — Feb 23rd, 2015
113
+
114
+ ### Configurable Socket Timeouts
115
+
116
+ Socket read and write timeouts are now configurable using
117
+ the `read_timeout` and `write_timeout` options, respectively.
118
+
119
+ Contributed by Chris Barton.
120
+
121
+
122
+ ### Logged Messages as Serialised as JSON
123
+
124
+ ...as opposed to Ruby object printing.
125
+
126
+ Contributed by Andrew Morton.
127
+
128
+
129
+ ### Configurable Heartbeat
130
+
131
+ Config now supports a new option: `:heartbeat`, which is passed
132
+ on to Bunny.
133
+
134
+ Contributed by Simon Taranto.
135
+
136
+
137
+ ### HoneyBadger Error Handler
138
+
139
+ Contributed by Daniel Farrell.
140
+
141
+
142
+ ### Hutch.connected? Now Returns Up-to-Date Value
143
+
144
+ `Hutch.connected?` no longer relies on an ivar and always returns
145
+ an up-to-date value.
146
+
147
+ Contributed by Pierre-Louis Gottfrois.
148
+
149
+
150
+ ## 0.13.0 — Dec 5th, 2014
151
+
152
+ ### HTTP API Can Be Disabled for Consumers
153
+
154
+ HTTP API use can be disabled for consumers using the `:enable_http_api_use` config
155
+ option (defaults to true).
156
+
157
+
158
+
159
+ ## 0.12.0 — Nov 25th, 2014
160
+
161
+ ### Explicit Requires
162
+
163
+ Hutch no longer relies on `Kernel#autoload` to load its key
164
+ modules and classes.
165
+
166
+ Contributed by Pierre-Louis Gottfrois.
167
+
168
+
169
+ ### hutch --version No Longer Fails
170
+
171
+ ```
172
+ hutch --version
173
+ ```
174
+
175
+ no longer fails with an exception.
176
+
177
+ Contributed by Olle Jonsson.
178
+
179
+
180
+ ### Base Class for All Hutch Exceptions
181
+
182
+ All Hutch exceptions now inherit from `Hutch::Exception`.
183
+
184
+ Contributed by Pierre-Louis Gottfrois.
185
+
186
+
187
+ ## 0.11.0 — Nov 14th, 2014
188
+
189
+ ### Publisher Confirms Support
190
+
191
+ `:force_publisher_confirms` is a new configuration option that forces `Hutch.publish` to wait
192
+ for a confirm for every message published. Note that this **will cause a significant drop in throughput**:
193
+
194
+ ``` ruby
195
+ Hutch::Config.set(:force_publisher_confirms, true)
196
+ ```
197
+
198
+ `Hutch::Broker#confirm_select` and `Hutch::Broker#wait_for_confirms` are new public API methods
199
+ that delegate to their respective `Bunny::Channel` counterparts. `Hutch::Broker#confirm_select`
200
+ can be used to handle confirms with a callback instead of waiting:
201
+
202
+ ``` ruby
203
+ broker.confirm_select do |delivery_tag, multiple, nack|
204
+ # ...
205
+ end
206
+ ```
207
+
208
+
209
+ ### Bunny Update
210
+
211
+ Bunny is updated to [1.6.0](http://blog.rubyrabbitmq.info/blog/2014/10/31/bunny-1-dot-6-0-is-released/).
212
+
213
+
214
+ ## 0.10.0 — Oct 22, 2014
215
+
216
+ ### Configuration via URI
217
+
218
+ Hutch now supports a new configuration key, `:uri`, which allows
219
+ connection configuration via a URI.
220
+
221
+ Note that since the URI has to include credentials, this option
222
+ is not available on the command line.
223
+
224
+ ### Bunny Update
225
+
226
+ Bunny is updated to `1.5.1`, which mitigates the POODLE attack
227
+ by disabling SSL 3.0 where possible.
228
+
229
+ ### Payload in Error Handlers
230
+
231
+ Error handlers will now have access to message payload.
232
+
233
+ Contributed by Daniel Farrell.
234
+
235
+ ### Exceptions in Error Handlers Don't Prevent Nacks
236
+
237
+ Exceptions in error handlers no longer prevent messages from being
238
+ `basic.nack`-ed.
239
+
240
+ ### Pid File Support
241
+
242
+ `:pidfile` is a new configuration option that stores Hutch process
243
+ PID in a file at provided path.
244
+
245
+ Contributed by Rustam Sharshenov.
246
+
247
+ ### More Info on Message
248
+
249
+ Bunny's `delivery_info`, `properties` and payload are now accessible on `Hutch::Message`.
250
+
251
+ Contributed by gregory.
252
+
253
+
254
+ ### Optional Config Parameters
255
+
256
+ `Hutch::Config` constructor now accepts an extra hash of optional
257
+ configuration parameters.
258
+
259
+ Contributed by Ignazio Mostallino.
260
+
261
+
262
+ ## 0.9.0 — May 13, 2014
263
+
264
+ ### Platform-aware Signal Registration
265
+
266
+ Hutch will no longer attempt to register signal traps
267
+ for signals not supported by the environment (e.g. on by certain OSes).
268
+
269
+ Contributed by Tobias Matthies.
270
+
271
+ ### TLS Fixes
272
+
273
+ Hutch now properly passes client TLS key and certificate to
274
+ Bunny.
275
+
276
+ Contributed by Eric Nelson.
277
+
278
+ ### Bunny Update
279
+
280
+ Bunny is updated to 1.2.x which should offer
281
+ [much better latency](https://github.com/ruby-amqp/bunny/pull/187) for
282
+ workloads with lots of small messages published frequently.
283
+
284
+ ### More Unit Testing Friendly CLI/Runner
285
+
286
+ `Hutch::CLI#run` now accepts a parameter and is easier to use
287
+ in automated tests.
288
+
289
+
290
+ ## 0.8.0 — February 13, 2014
291
+
292
+ ### Uncaught Exceptions Result in Rejected Messages
293
+
294
+ Uncaught exceptions in consumers now result in Hutch rejecting
295
+ messages (deliveries) using `basic.nack`. This way they are [dead lettered](http://www.rabbitmq.com/dlx.html).
296
+
297
+ Contributed by Garrett Johnson.
298
+
299
+ ### Missing Require
300
+
301
+ `hutch/consumer.rb` no longer fails to load with the
302
+ apps that do not `require "set"`.
303
+
304
+ Contributed by Garrett Johnson.
305
+
306
+ ### Relaxed Queue Namespace Validation
307
+
308
+ Namespaces now can include any characters that are valid in RabbitMQ
309
+ queue names.
310
+
311
+ Contributed by Garrett Johnson.
312
+
313
+ ### basic.qos Configuration
314
+
315
+ It is now possible to configure `basic.qos` (aka channel prefetch) setting
316
+ used by Hutch using the `:channel_prefetch` config key.
317
+
318
+ ### Passwords No Longer Logged
319
+
320
+ Hutch now elides passwords from logs.
321
+
322
+
323
+ ## 0.7.0 — January 14, 2014
324
+
325
+ ### Optional HTTP API Use
326
+
327
+ It is now possible to make Hutch [not use RabbitMQ HTTP
328
+ API](https://github.com/gocardless/hutch/pull/69) (e.g. when the
329
+ RabbitMQ management plugin that provides it is not available).
330
+
331
+
332
+ ### Extra Arguments for Hutch::Broker#publish
333
+
334
+ Extra options [passed to `Hutch::Broker#publish` will now be propagated](https://github.com/gocardless/hutch/pull/61).
335
+
336
+
337
+ ### Content-Type for Messages
338
+
339
+ Messages published with Hutch now have content type set
340
+ to `application/json`.
341
+
342
+
343
+ ### Greater Heartbeat Interval
344
+
345
+ Hutch now uses heartbeat interval of 30, so heartbeats won't interfere with transfers
346
+ of large messages over high latency networks (e.g. between AWS availability regions).
347
+
348
+
349
+ ### Custom Queue Names
350
+
351
+ It is now possible to [specify an optional queue name](https://github.com/gocardless/hutch/pull/49):
352
+
353
+ ``` ruby
354
+ class FailedPaymentConsumer
355
+ include Hutch::Consumer
356
+ consume 'gc.ps.payment.failed'
357
+ queue_name 'failed_payments'
358
+
359
+ def process(message)
360
+ mark_payment_as_failed(message[:id])
361
+ end
362
+ end
363
+ ```
364
+
365
+ ### Global Properties for Publishers
366
+
367
+ [Global properties can now be specified](https://github.com/gocardless/hutch/pull/62) for publishing:
368
+
369
+ ``` ruby
370
+ Hutch.global_properties = proc {
371
+ { app_id: 'api', headers: { request_id: RequestId.request_id } }
372
+ }
373
+ ```
374
+
375
+ ## 0.6.0 - November 4, 2013
376
+
377
+ - Metadata can now be passed in to `#publish`
378
+
379
+ ## 0.5.1 - October 17, 2013
380
+
381
+ - Raise an exception when publishing fails
382
+
383
+ ## 0.5.0 - October 17, 2013
384
+
385
+ - Support for the `--mq-tls-key` and `--mq-tls-cert` configuration options.
386
+
387
+ ## 0.4.5 - October 15, 2013
388
+
389
+ - No exception raised when hutch is run with no consumers. Instead, a warning
390
+ is logged.
391
+ - Internal refactoring: use Bunny's shiny `ConsumerWorkPool#threads`
392
+ attr_reader.
393
+
394
+ ## 0.4.4 - October 12, 2013
395
+
396
+ - Friendlier Message#inspect, doesn't spew out detailed bunny info.
397
+
398
+ ## 0.4.3 - October 11, 2013
399
+
400
+ - More autoloading tweaks, all internal modules are now autoloaded.
401
+
402
+ ## 0.4.2 - October 11, 2013
403
+
404
+ - Autoload the Broker module, which was missed in the previous release.
405
+
406
+ ## 0.4.1 - October 11, 2013
407
+
408
+ - Autoload internal modules. Fixes regression where the `Config` module was
409
+ not available by simply `require`ing `hutch`.
410
+
411
+ ## 0.4.0 - October 9, 2013
412
+
413
+ - Support for loading configuration from a file, specified with the `--config`
414
+ command line option.
415
+
416
+ ## 0.3.0 - September 24, 2013
417
+
418
+ - Add `--[no-]autoload-rails` flag to optionally disable the autoloading of
419
+ Rails apps in the current directory
420
+
421
+ ## 0.2.1 - September 17, 2013
422
+
423
+ - Fix inconsistency with `mq-tls` option
424
+
425
+ ## 0.2.0 - September 16, 2013
426
+
427
+ - Support for connecting to RabbitMQ with TLS/SSL. There are two new
428
+ configuration options : `mq-tls` and `mq-api-ssl`.
429
+ - JSON message parsing errors are now handled properly.
430
+
431
+ ## 0.1.1 - September 9, 2013
432
+
433
+ - Relax Bunny dependency specification
434
+
435
+ ## 0.1.0 - September 9, 2013
436
+
437
+ - Initial release
438
+