hutch 1.4.0 → 2.0.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 +4 -4
- data/CHANGELOG.md +61 -0
- data/LICENSE +1 -1
- data/README.md +42 -42
- data/lib/hutch/acknowledgements/nack_on_all_failures.rb +1 -1
- data/lib/hutch/adapters/bunny.rb +24 -0
- data/lib/hutch/adapters/march_hare.rb +21 -1
- data/lib/hutch/broker.rb +67 -34
- data/lib/hutch/cli.rb +1 -4
- data/lib/hutch/config.rb +3 -3
- data/lib/hutch/consumer.rb +3 -3
- data/lib/hutch/error_handlers.rb +0 -1
- data/lib/hutch/serializers/json.rb +3 -3
- data/lib/hutch/tracers/datadog.rb +2 -9
- data/lib/hutch/version.rb +1 -1
- data/lib/hutch/worker.rb +39 -4
- data/lib/yard-settings/yard-settings.rb +2 -2
- data/spec/hutch/broker_spec.rb +166 -2
- data/spec/hutch/cli_spec.rb +12 -9
- data/spec/hutch/error_handlers/airbrake_spec.rb +3 -0
- data/spec/hutch/message_spec.rb +1 -1
- data/spec/hutch/worker_spec.rb +62 -8
- data/spec/integration/channel_recovery_spec.rb +71 -23
- data/spec/integration/publish_consume_spec.rb +1 -2
- metadata +6 -36
- data/.github/workflows/test.yml +0 -74
- data/.gitignore +0 -10
- data/.rspec +0 -1
- data/.yardopts +0 -5
- data/AGENTS.md +0 -127
- data/Gemfile +0 -35
- data/Guardfile +0 -14
- data/Rakefile +0 -21
- data/examples/consumer.rb +0 -13
- data/examples/producer.rb +0 -10
- data/hutch.gemspec +0 -27
- data/lib/hutch/error_handlers/sentry_raven.rb +0 -34
- data/spec/hutch/error_handlers/sentry_raven_spec.rb +0 -37
- data/spec/spec_helper.rb +0 -42
|
@@ -3,7 +3,6 @@ require 'hutch/broker'
|
|
|
3
3
|
require 'hutch/worker'
|
|
4
4
|
require 'hutch/consumer'
|
|
5
5
|
require 'securerandom'
|
|
6
|
-
require 'timeout'
|
|
7
6
|
|
|
8
7
|
describe 'publishing and consuming messages', rabbitmq: true, adapter: :bunny do
|
|
9
8
|
let(:exchange_name) { "hutch.test.#{SecureRandom.hex(4)}" }
|
|
@@ -41,7 +40,7 @@ describe 'publishing and consuming messages', rabbitmq: true, adapter: :bunny do
|
|
|
41
40
|
|
|
42
41
|
broker.publish(routing_key, { test: 'data' })
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
await_condition(15, 'message consumption') { received.any? }
|
|
45
44
|
|
|
46
45
|
expect(received.first).to eq('test' => 'data')
|
|
47
46
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hutch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Harry Marr
|
|
8
8
|
- Michael Klishin
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bunny
|
|
@@ -16,7 +16,7 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '3.
|
|
19
|
+
version: '3.2'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
22
|
version: '4.0'
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '3.
|
|
29
|
+
version: '3.2'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: '4.0'
|
|
@@ -44,20 +44,6 @@ dependencies:
|
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
46
|
version: 0.0.7
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: multi_json
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '1.15'
|
|
54
|
-
type: :runtime
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '1.15'
|
|
61
47
|
- !ruby/object:Gem::Dependency
|
|
62
48
|
name: activesupport
|
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -79,24 +65,13 @@ executables:
|
|
|
79
65
|
extensions: []
|
|
80
66
|
extra_rdoc_files: []
|
|
81
67
|
files:
|
|
82
|
-
- ".github/workflows/test.yml"
|
|
83
|
-
- ".gitignore"
|
|
84
|
-
- ".rspec"
|
|
85
|
-
- ".yardopts"
|
|
86
|
-
- AGENTS.md
|
|
87
68
|
- CHANGELOG.md
|
|
88
|
-
- Gemfile
|
|
89
|
-
- Guardfile
|
|
90
69
|
- LICENSE
|
|
91
70
|
- README.md
|
|
92
|
-
- Rakefile
|
|
93
71
|
- bin/ci/before_build.sh
|
|
94
72
|
- bin/ci/before_build_docker.sh
|
|
95
73
|
- bin/ci/install_on_debian.sh
|
|
96
74
|
- bin/hutch
|
|
97
|
-
- examples/consumer.rb
|
|
98
|
-
- examples/producer.rb
|
|
99
|
-
- hutch.gemspec
|
|
100
75
|
- lib/hutch.rb
|
|
101
76
|
- lib/hutch/acknowledgements/base.rb
|
|
102
77
|
- lib/hutch/acknowledgements/nack_on_all_failures.rb
|
|
@@ -115,7 +90,6 @@ files:
|
|
|
115
90
|
- lib/hutch/error_handlers/logger.rb
|
|
116
91
|
- lib/hutch/error_handlers/rollbar.rb
|
|
117
92
|
- lib/hutch/error_handlers/sentry.rb
|
|
118
|
-
- lib/hutch/error_handlers/sentry_raven.rb
|
|
119
93
|
- lib/hutch/exceptions.rb
|
|
120
94
|
- lib/hutch/logging.rb
|
|
121
95
|
- lib/hutch/message.rb
|
|
@@ -140,7 +114,6 @@ files:
|
|
|
140
114
|
- spec/hutch/error_handlers/honeybadger_spec.rb
|
|
141
115
|
- spec/hutch/error_handlers/logger_spec.rb
|
|
142
116
|
- spec/hutch/error_handlers/rollbar_spec.rb
|
|
143
|
-
- spec/hutch/error_handlers/sentry_raven_spec.rb
|
|
144
117
|
- spec/hutch/error_handlers/sentry_spec.rb
|
|
145
118
|
- spec/hutch/logger_spec.rb
|
|
146
119
|
- spec/hutch/message_spec.rb
|
|
@@ -151,7 +124,6 @@ files:
|
|
|
151
124
|
- spec/hutch_spec.rb
|
|
152
125
|
- spec/integration/channel_recovery_spec.rb
|
|
153
126
|
- spec/integration/publish_consume_spec.rb
|
|
154
|
-
- spec/spec_helper.rb
|
|
155
127
|
- templates/default/class/html/settings.erb
|
|
156
128
|
- templates/default/class/setup.rb
|
|
157
129
|
- templates/default/fulldoc/html/css/hutch.css
|
|
@@ -172,14 +144,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
172
144
|
requirements:
|
|
173
145
|
- - ">="
|
|
174
146
|
- !ruby/object:Gem::Version
|
|
175
|
-
version: '3.
|
|
147
|
+
version: '3.2'
|
|
176
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
149
|
requirements:
|
|
178
150
|
- - ">="
|
|
179
151
|
- !ruby/object:Gem::Version
|
|
180
152
|
version: '0'
|
|
181
153
|
requirements: []
|
|
182
|
-
rubygems_version:
|
|
154
|
+
rubygems_version: 4.0.16
|
|
183
155
|
specification_version: 4
|
|
184
156
|
summary: Opinionated asynchronous inter-service communication using RabbitMQ
|
|
185
157
|
test_files:
|
|
@@ -192,7 +164,6 @@ test_files:
|
|
|
192
164
|
- spec/hutch/error_handlers/honeybadger_spec.rb
|
|
193
165
|
- spec/hutch/error_handlers/logger_spec.rb
|
|
194
166
|
- spec/hutch/error_handlers/rollbar_spec.rb
|
|
195
|
-
- spec/hutch/error_handlers/sentry_raven_spec.rb
|
|
196
167
|
- spec/hutch/error_handlers/sentry_spec.rb
|
|
197
168
|
- spec/hutch/logger_spec.rb
|
|
198
169
|
- spec/hutch/message_spec.rb
|
|
@@ -203,4 +174,3 @@ test_files:
|
|
|
203
174
|
- spec/hutch_spec.rb
|
|
204
175
|
- spec/integration/channel_recovery_spec.rb
|
|
205
176
|
- spec/integration/publish_consume_spec.rb
|
|
206
|
-
- spec/spec_helper.rb
|
data/.github/workflows/test.yml
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
concurrency:
|
|
4
|
-
group: ${{ github.ref }}
|
|
5
|
-
cancel-in-progress: true
|
|
6
|
-
|
|
7
|
-
on:
|
|
8
|
-
push:
|
|
9
|
-
branches:
|
|
10
|
-
- "main"
|
|
11
|
-
pull_request:
|
|
12
|
-
branches:
|
|
13
|
-
- "main"
|
|
14
|
-
workflow_dispatch:
|
|
15
|
-
|
|
16
|
-
jobs:
|
|
17
|
-
test:
|
|
18
|
-
name: RabbitMQ ${{ matrix.rabbitmq }}, Ruby ${{ matrix.ruby }}
|
|
19
|
-
runs-on: ubuntu-latest
|
|
20
|
-
|
|
21
|
-
strategy:
|
|
22
|
-
fail-fast: false
|
|
23
|
-
matrix:
|
|
24
|
-
ruby:
|
|
25
|
-
- "4.0"
|
|
26
|
-
- "3.4"
|
|
27
|
-
- "3.3"
|
|
28
|
-
- "3.2"
|
|
29
|
-
- "3.1"
|
|
30
|
-
- "3.0"
|
|
31
|
-
rabbitmq:
|
|
32
|
-
- "4.2"
|
|
33
|
-
- "4.1"
|
|
34
|
-
- "4.0"
|
|
35
|
-
- "3.13"
|
|
36
|
-
|
|
37
|
-
env:
|
|
38
|
-
CI: true
|
|
39
|
-
|
|
40
|
-
services:
|
|
41
|
-
rabbitmq:
|
|
42
|
-
image: rabbitmq:${{ matrix.rabbitmq }}-management
|
|
43
|
-
ports:
|
|
44
|
-
- 5672:5672
|
|
45
|
-
- 15672:15672
|
|
46
|
-
options: --name rabbitmq
|
|
47
|
-
|
|
48
|
-
steps:
|
|
49
|
-
- uses: actions/checkout@v4
|
|
50
|
-
|
|
51
|
-
- name: Set up Ruby ${{ matrix.ruby }}
|
|
52
|
-
uses: ruby/setup-ruby@v1
|
|
53
|
-
with:
|
|
54
|
-
ruby-version: ${{ matrix.ruby }}
|
|
55
|
-
bundler-cache: true
|
|
56
|
-
|
|
57
|
-
- name: Wait for RabbitMQ to start
|
|
58
|
-
run: sleep 10
|
|
59
|
-
|
|
60
|
-
- name: Set up RabbitMQ
|
|
61
|
-
run: ./bin/ci/before_build_docker.sh
|
|
62
|
-
|
|
63
|
-
- name: Run tests
|
|
64
|
-
run: bundle exec rspec spec
|
|
65
|
-
|
|
66
|
-
test_all:
|
|
67
|
-
if: ${{ always() }}
|
|
68
|
-
runs-on: ubuntu-latest
|
|
69
|
-
name: Test (matrix)
|
|
70
|
-
needs: test
|
|
71
|
-
steps:
|
|
72
|
-
- name: Check test matrix status
|
|
73
|
-
if: ${{ needs.test.result != 'success' }}
|
|
74
|
-
run: exit 1
|
data/.gitignore
DELETED
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--order random
|
data/.yardopts
DELETED
data/AGENTS.md
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
# Instructions for AI Agents
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Hutch is a Ruby library for enabling asynchronous inter-service communication
|
|
6
|
-
using RabbitMQ. It provides a conventions-based framework for consumers and
|
|
7
|
-
producers using topic exchanges.
|
|
8
|
-
|
|
9
|
-
Its key dependencies are [Bunny](https://github.com/ruby-amqp/bunny) (MRI Ruby)
|
|
10
|
-
or [March Hare](https://github.com/ruby-amqp/march_hare) (JRuby), two RabbitMQ clients that use AMQP 0-9-1.
|
|
11
|
-
|
|
12
|
-
On top, Hutch uses [carrot-top](https://github.com/change/carrot-top) for the RabbitMQ HTTP API,
|
|
13
|
-
and [ActiveSupport](https://github.com/rails/rails/tree/main/activesupport) from Ruby on Rails.
|
|
14
|
-
|
|
15
|
-
## Target Ruby Version
|
|
16
|
-
|
|
17
|
-
This library targets Ruby 3.0 and later versions
|
|
18
|
-
For JRuby, the supported series are 9.x and 10.x.
|
|
19
|
-
|
|
20
|
-
## Build and Test
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
bundle install
|
|
24
|
-
|
|
25
|
-
bundle exec rspec spec
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
To run tests use `rspec` directly (not Rake).
|
|
29
|
-
|
|
30
|
-
## Key Files
|
|
31
|
-
|
|
32
|
-
### Core
|
|
33
|
-
|
|
34
|
-
* `lib/hutch.rb`: top-level module, global consumer registry, a connection singleton
|
|
35
|
-
* `lib/hutch/broker.rb`: RabbitMQ connection and channel lifecycle, topology declaration, [delivery acknowledgements](https://www.rabbitmq.com/docs/confirms), [publisher confirms](https://www.rabbitmq.com/docs/confirms), [TLS](https://www.rabbitmq.com/docs/ssl), HTTP API client
|
|
36
|
-
* `lib/hutch/worker.rb`: the main consumer loop: topology and consumer setup, delivery dispatch, error handling
|
|
37
|
-
* `lib/hutch/consumer.rb`: `Hutch::Consumer` module included by consumer classes; DSL: `consume`, `queue_name`, `lazy_queue`, `quorum_queue`, `arguments`, `queue_options`, `serializer`
|
|
38
|
-
* `lib/hutch/publisher.rb`: message serialization, routing, publisher confirms
|
|
39
|
-
* `lib/hutch/message.rb`: message wrapper (delivery_info, properties, payload)
|
|
40
|
-
* `lib/hutch/config.rb`: configuration with 3-tier precedence (defaults < ENV `HUTCH_*` < config file < explicit set)
|
|
41
|
-
* `lib/hutch/cli.rb`: CLI (based on `OptionParser`), Rails app detection, consumer loading, daemonization
|
|
42
|
-
* `lib/hutch/exceptions.rb`: `ConnectionError`, `AuthenticationError`, `WorkerSetupError`, `PublishError`
|
|
43
|
-
* `lib/hutch/logging.rb`: configurable logger with `HutchFormatter`
|
|
44
|
-
* `lib/hutch/waiter.rb`: signal handling (`SIGINT`, `SIGTERM`, `SIGQUIT` for shutdown; `SIGUSR2` for thread dumps)
|
|
45
|
-
* `lib/hutch/version.rb`: the `Hutch::VERSION` constant
|
|
46
|
-
|
|
47
|
-
### Adapters
|
|
48
|
-
|
|
49
|
-
* `lib/hutch/adapter.rb`: runtime adapter selector (Bunny on MRI, March Hare on JRuby)
|
|
50
|
-
* `lib/hutch/adapters/bunny.rb`: Bunny adapter
|
|
51
|
-
* `lib/hutch/adapters/march_hare.rb`: March Hare adapter
|
|
52
|
-
|
|
53
|
-
### Serializers
|
|
54
|
-
|
|
55
|
-
* `lib/hutch/serializers/json.rb`: JSON serialization via `multi_json`
|
|
56
|
-
* `lib/hutch/serializers/identity.rb`: pass-through (no-op) serializer
|
|
57
|
-
|
|
58
|
-
### Error Handlers
|
|
59
|
-
|
|
60
|
-
* `lib/hutch/error_handlers/base.rb`: base class
|
|
61
|
-
* `lib/hutch/error_handlers/logger.rb`: logs errors (default)
|
|
62
|
-
* `lib/hutch/error_handlers/sentry.rb`: sentry-ruby integration
|
|
63
|
-
* `lib/hutch/error_handlers/sentry_raven.rb`: legacy sentry-raven integration
|
|
64
|
-
* `lib/hutch/error_handlers/honeybadger.rb`: Honeybadger
|
|
65
|
-
* `lib/hutch/error_handlers/airbrake.rb`: Airbrake
|
|
66
|
-
* `lib/hutch/error_handlers/rollbar.rb`: Rollbar
|
|
67
|
-
* `lib/hutch/error_handlers/bugsnag.rb`: Bugsnag
|
|
68
|
-
|
|
69
|
-
### Tracers
|
|
70
|
-
|
|
71
|
-
* `lib/hutch/tracers/null_tracer.rb`: no-op (default)
|
|
72
|
-
* `lib/hutch/tracers/newrelic.rb`: NewRelic APM
|
|
73
|
-
* `lib/hutch/tracers/datadog.rb`: Datadog tracing
|
|
74
|
-
|
|
75
|
-
### Acknowledgement Strategies
|
|
76
|
-
|
|
77
|
-
* `lib/hutch/acknowledgements/base.rb`: base interface (a chain of responsibility)
|
|
78
|
-
* `lib/hutch/acknowledgements/nack_on_all_failures.rb`: the default fallback
|
|
79
|
-
|
|
80
|
-
## Test Suite
|
|
81
|
-
|
|
82
|
-
The test suite uses RSpec:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
bundle exec rspec spec
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Test files mirror the `lib/hutch/` structure under `spec/hutch/`. Tests are filtered
|
|
89
|
-
by adapter at runtime: Bunny specs are excluded on JRuby, March Hare specs on MRI.
|
|
90
|
-
|
|
91
|
-
## Comments
|
|
92
|
-
|
|
93
|
-
* Only add important comments that express the non-obvious intent, both in tests and in the implementation
|
|
94
|
-
* Keep the comments short
|
|
95
|
-
* Pay attention to the grammar of your comments, including punctuation, full stops, articles, and so on
|
|
96
|
-
|
|
97
|
-
## Change Log
|
|
98
|
-
|
|
99
|
-
If asked to perform change log updates, consult and modify `CHANGELOG.md` and stick to its
|
|
100
|
-
existing writing style.
|
|
101
|
-
|
|
102
|
-
## Releases
|
|
103
|
-
|
|
104
|
-
### How to Roll (Produce) a New Release
|
|
105
|
-
|
|
106
|
-
Suppose the current development version in `CHANGELOG.md` has
|
|
107
|
-
a `## X.Y.0 (in development)` section at the top.
|
|
108
|
-
|
|
109
|
-
To produce a new release:
|
|
110
|
-
|
|
111
|
-
1. Update `CHANGELOG.md`: replace `(in development)` with today's date, e.g. `(Mar 30, 2026)`. Make sure all notable changes since the previous release are listed
|
|
112
|
-
2. Update the version in `lib/hutch/version.rb` to match (remove the `.pre` suffix)
|
|
113
|
-
3. Commit with the message `X.Y.0` (just the version number, nothing else)
|
|
114
|
-
4. Tag the commit: `git tag vX.Y.0`
|
|
115
|
-
5. Bump the dev version: add a new `## X.(Y+1).0 (in development)` section to `CHANGELOG.md` with `No changes yet.` underneath, and update `lib/hutch/version.rb` to the next dev version with a `.pre` suffix
|
|
116
|
-
6. Commit with the message `Bump dev version`
|
|
117
|
-
7. Push: `git push && git push origin vX.(Y+1).0`
|
|
118
|
-
|
|
119
|
-
## Git Instructions
|
|
120
|
-
|
|
121
|
-
* Do not commit changes automatically without an explicit permission to do so
|
|
122
|
-
* Never add yourself to the list of commit co-authors
|
|
123
|
-
* Never mention yourself in commit messages in any way (no "Generated by", no AI tool links, etc)
|
|
124
|
-
|
|
125
|
-
## Style Guide
|
|
126
|
-
|
|
127
|
-
* Never add full stops to Markdown list items
|
data/Gemfile
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
ruby '>= 3.0.0'
|
|
4
|
-
|
|
5
|
-
gemspec
|
|
6
|
-
|
|
7
|
-
group :development do
|
|
8
|
-
gem "rake"
|
|
9
|
-
gem "guard", "~> 2.14", platform: :mri
|
|
10
|
-
gem "guard-rspec", "~> 4.7", platform: :mri
|
|
11
|
-
|
|
12
|
-
gem "yard", "~> 0.9"
|
|
13
|
-
gem 'kramdown', "> 0", platform: :jruby
|
|
14
|
-
gem "redcarpet", "> 0", platform: :mri
|
|
15
|
-
gem "github-markup", "> 0"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
group :development, :test do
|
|
19
|
-
gem "rspec", "~> 3.12"
|
|
20
|
-
gem "simplecov", "~> 0.21"
|
|
21
|
-
|
|
22
|
-
gem "sentry-raven"
|
|
23
|
-
gem "sentry-ruby"
|
|
24
|
-
gem "honeybadger"
|
|
25
|
-
gem "newrelic_rpm"
|
|
26
|
-
gem "datadog"
|
|
27
|
-
gem "airbrake", "~> 13.0"
|
|
28
|
-
gem "rollbar"
|
|
29
|
-
gem "bugsnag"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
group :development, :darwin do
|
|
33
|
-
gem "rb-fsevent", "~> 0.11.2"
|
|
34
|
-
gem "growl", "~> 1.0.3"
|
|
35
|
-
end
|
data/Guardfile
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
guard :rspec, cmd: "bundle exec rspec" do
|
|
2
|
-
require "guard/rspec/dsl"
|
|
3
|
-
dsl = Guard::RSpec::Dsl.new(self)
|
|
4
|
-
|
|
5
|
-
# RSpec files
|
|
6
|
-
rspec = dsl.rspec
|
|
7
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
8
|
-
watch(rspec.spec_support) { rspec.spec_dir }
|
|
9
|
-
watch(rspec.spec_files)
|
|
10
|
-
|
|
11
|
-
# Ruby files
|
|
12
|
-
ruby = dsl.ruby
|
|
13
|
-
dsl.watch_spec_files_for(ruby.lib_files)
|
|
14
|
-
end
|
data/Rakefile
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'rspec/core/rake_task'
|
|
2
|
-
|
|
3
|
-
desc "Run an IRB session with Hutch pre-loaded"
|
|
4
|
-
task :console do
|
|
5
|
-
exec "irb -I lib -r hutch"
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
desc "Run the test suite"
|
|
9
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
10
|
-
t.pattern = FileList['spec/**/*_spec.rb']
|
|
11
|
-
t.rspec_opts = %w(--color --format doc)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
task default: :spec
|
|
15
|
-
|
|
16
|
-
#
|
|
17
|
-
# Re-generate API docs
|
|
18
|
-
#
|
|
19
|
-
require 'yard'
|
|
20
|
-
require 'yard/rake/yardoc_task'
|
|
21
|
-
YARD::Rake::YardocTask.new
|
data/examples/consumer.rb
DELETED
data/examples/producer.rb
DELETED
data/hutch.gemspec
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../lib/hutch/version', __FILE__)
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new do |gem|
|
|
4
|
-
if defined?(JRUBY_VERSION)
|
|
5
|
-
gem.platform = 'java'
|
|
6
|
-
gem.add_runtime_dependency 'march_hare', '>= 4.7.0'
|
|
7
|
-
else
|
|
8
|
-
gem.platform = Gem::Platform::RUBY
|
|
9
|
-
gem.add_runtime_dependency 'bunny', '>= 3.1', '< 4.0'
|
|
10
|
-
end
|
|
11
|
-
gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
|
|
12
|
-
gem.add_runtime_dependency 'multi_json', '~> 1.15'
|
|
13
|
-
gem.add_runtime_dependency 'activesupport', '>= 4.2'
|
|
14
|
-
|
|
15
|
-
gem.name = 'hutch'
|
|
16
|
-
gem.summary = 'Opinionated asynchronous inter-service communication using RabbitMQ'
|
|
17
|
-
gem.description = 'Hutch is a Ruby library for enabling asynchronous inter-service communication using RabbitMQ'
|
|
18
|
-
gem.version = Hutch::VERSION.dup
|
|
19
|
-
gem.required_ruby_version = '>= 3.0'
|
|
20
|
-
gem.authors = ['Harry Marr', 'Michael Klishin']
|
|
21
|
-
gem.homepage = 'https://github.com/ruby-amqp/hutch'
|
|
22
|
-
gem.require_paths = ['lib']
|
|
23
|
-
gem.license = 'MIT'
|
|
24
|
-
gem.executables = ['hutch']
|
|
25
|
-
gem.files = `git ls-files`.split("\n")
|
|
26
|
-
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
|
27
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'hutch/logging'
|
|
2
|
-
require 'raven'
|
|
3
|
-
require 'hutch/error_handlers/base'
|
|
4
|
-
|
|
5
|
-
module Hutch
|
|
6
|
-
module ErrorHandlers
|
|
7
|
-
class SentryRaven < Base
|
|
8
|
-
|
|
9
|
-
def initialize
|
|
10
|
-
unless Raven.respond_to?(:capture_exception)
|
|
11
|
-
raise "The Hutch Sentry error handler requires Raven >= 0.4.0"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
warn "[DEPRECATION] Hutch::ErrorHandlers::SentryRaven is deprecated and will be removed in Hutch 2.0. " \
|
|
15
|
-
"Use Hutch::ErrorHandlers::Sentry (backed by the sentry-ruby gem) instead." \
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def handle(properties, payload, consumer, ex)
|
|
19
|
-
message_id = properties.message_id
|
|
20
|
-
prefix = "message(#{message_id || '-'}):"
|
|
21
|
-
logger.error "#{prefix} Logging event to Sentry"
|
|
22
|
-
logger.error "#{prefix} #{ex.class} - #{ex.message}"
|
|
23
|
-
Raven.capture_exception(ex, extra: { payload: payload })
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def handle_setup_exception(ex)
|
|
27
|
-
logger.error "Logging setup exception to Sentry"
|
|
28
|
-
logger.error "#{ex.class} - #{ex.message}"
|
|
29
|
-
Raven.capture_exception(ex)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Hutch::ErrorHandlers::SentryRaven do
|
|
4
|
-
let(:error_handler) { Hutch::ErrorHandlers::SentryRaven.new }
|
|
5
|
-
|
|
6
|
-
describe '#handle' do
|
|
7
|
-
let(:properties) { Struct.new(:message_id).new("1") }
|
|
8
|
-
let(:payload) { "{}" }
|
|
9
|
-
let(:error) do
|
|
10
|
-
begin
|
|
11
|
-
raise "Stuff went wrong"
|
|
12
|
-
rescue RuntimeError => err
|
|
13
|
-
err
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "logs the error to Sentry" do
|
|
18
|
-
expect(Raven).to receive(:capture_exception).with(error, {extra: { payload: payload }})
|
|
19
|
-
error_handler.handle(properties, payload, double, error)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe '#handle_setup_exception' do
|
|
24
|
-
let(:error) do
|
|
25
|
-
begin
|
|
26
|
-
raise "Stuff went wrong during setup"
|
|
27
|
-
rescue RuntimeError => err
|
|
28
|
-
err
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "logs the error to Sentry" do
|
|
33
|
-
expect(Raven).to receive(:capture_exception).with(error)
|
|
34
|
-
error_handler.handle_setup_exception(error)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require 'simplecov'
|
|
2
|
-
if ENV['TRAVIS']
|
|
3
|
-
require 'coveralls'
|
|
4
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
SimpleCov.start do
|
|
8
|
-
add_filter '/spec/'
|
|
9
|
-
add_filter '/.bundle/'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
require 'raven'
|
|
13
|
-
require 'hutch'
|
|
14
|
-
require 'logger'
|
|
15
|
-
|
|
16
|
-
# set logger to be a null logger
|
|
17
|
-
Hutch::Logging.logger = Logger.new(File::NULL)
|
|
18
|
-
|
|
19
|
-
RSpec.configure do |config|
|
|
20
|
-
config.raise_errors_for_deprecations!
|
|
21
|
-
|
|
22
|
-
if defined?(JRUBY_VERSION)
|
|
23
|
-
config.filter_run_excluding adapter: :bunny
|
|
24
|
-
else
|
|
25
|
-
config.filter_run_excluding adapter: :march_hare
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
config.mock_with :rspec do |mocks|
|
|
29
|
-
mocks.verify_partial_doubles = true
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Constants (classes, etc) defined within a block passed to this method
|
|
34
|
-
# will be removed from the global namespace after the block as run.
|
|
35
|
-
def isolate_constants
|
|
36
|
-
existing_constants = Object.constants
|
|
37
|
-
yield
|
|
38
|
-
ensure
|
|
39
|
-
(Object.constants - existing_constants).each do |constant|
|
|
40
|
-
Object.send(:remove_const, constant)
|
|
41
|
-
end
|
|
42
|
-
end
|