hutch 0.28.0 → 1.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/.travis.yml +4 -3
- data/CHANGELOG.md +73 -1
- data/LICENSE +1 -0
- data/hutch.gemspec +1 -1
- data/lib/hutch/broker.rb +2 -1
- data/lib/hutch/config.rb +3 -0
- data/lib/hutch/consumer.rb +15 -8
- data/lib/hutch/version.rb +1 -1
- data/spec/hutch/consumer_spec.rb +36 -24
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 626b85f02b69ee2113376ff382173fd124cdcae1bdc404f0681874e76a80310e
|
4
|
+
data.tar.gz: 3d1d6a2cd275b1c2d72d4842841ad90f70145cabe6800ff3860b206aebf0308e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1b0c80bf6362b0cfbc6f54b3257c74549c6d927fbae3bcaecb50aeb4ed0f28e01466a6a3013ce9175f55eb481b2e9378f89954edcc1453753da00b76873c766
|
7
|
+
data.tar.gz: 4c346421c5c1fa49440866b56486cc75d68c3eed8c3014ae2f51e2643f40a59b084634248b52d32965b65f692d1560250a8f5add30c4b75b2f541c895574aa26
|
data/.travis.yml
CHANGED
@@ -11,9 +11,10 @@ before_script:
|
|
11
11
|
- "./bin/ci/before_build.sh"
|
12
12
|
matrix:
|
13
13
|
include:
|
14
|
-
- rvm: "2.
|
15
|
-
- rvm: "2.
|
16
|
-
- rvm: "2.
|
14
|
+
- rvm: "2.7.1"
|
15
|
+
- rvm: "2.6.6"
|
16
|
+
- rvm: "2.5.8"
|
17
|
+
- rvm: "2.4.10"
|
17
18
|
- rvm: "2.3.8"
|
18
19
|
- rvm: "jruby-9.2.9.0"
|
19
20
|
- rvm: "ruby-head"
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,76 @@
|
|
1
|
-
## 0.
|
1
|
+
## 1.0.1 (in development)
|
2
|
+
|
3
|
+
No changes yet.
|
4
|
+
|
5
|
+
## 1.0.0 (April 8th, 2020)
|
6
|
+
|
7
|
+
Hutch has been around for several years. It is time to ship a 1.0. With it we try to correct
|
8
|
+
a few of overly opinionated decisions from recent releases. This means this release
|
9
|
+
contains potentially breaking changes.
|
10
|
+
|
11
|
+
### Breaking Changes
|
12
|
+
|
13
|
+
* Hutch will no longer configure any queue type (such as [quorum queues](https://www.rabbitmq.com/quorum-queues.html))
|
14
|
+
or queue mode (used by classic [lazy queues](https://www.rabbitmq.com/lazy-queues.html))
|
15
|
+
by default as that can be breaking change for existing Hutch and RabbitMQ installations due to the
|
16
|
+
[property equivalence requirement](https://www.rabbitmq.com/queues.html#property-equivalence) in AMQP 0-9-1.
|
17
|
+
|
18
|
+
This means **some defaults introduced in `0.28.0` ([gocardless/hutch#341](https://github.com/gocardless/hutch/pull/341)) were reverted**.
|
19
|
+
The user has to opt in to configure the queue type and mode and other [optional arguments](https://www.rabbitmq.com/queues.html#optional-arguments) they need to use.
|
20
|
+
Most optional arguments can be set via [policies](https://www.rabbitmq.com/parameters.html#policies) which is always the recommended approach.
|
21
|
+
Queue type, unfortunately, is not one of them as different queue types have completely different
|
22
|
+
implementation details, on disk data formats and so on.
|
23
|
+
|
24
|
+
To use a quorum queue, use the `quorum_queue` consumer DSL method:
|
25
|
+
|
26
|
+
``` ruby
|
27
|
+
class ConsumerUsingQuorumQueue
|
28
|
+
include Hutch::Consumer
|
29
|
+
consume 'hutch.test1'
|
30
|
+
# when in doubt, prefer using a policy to this DSL
|
31
|
+
# https://www.rabbitmq.com/parameters.html#policies
|
32
|
+
arguments 'x-key': :value
|
33
|
+
|
34
|
+
quorum_queue
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
To use a classic lazy queue, use the `lazy_queue` consumer DSL method:
|
39
|
+
|
40
|
+
``` ruby
|
41
|
+
class ConsumerUsingLazyQueue
|
42
|
+
include Hutch::Consumer
|
43
|
+
consume 'hutch.test1'
|
44
|
+
# when in doubt, prefer using a policy to this DSL
|
45
|
+
# https://www.rabbitmq.com/parameters.html#policies
|
46
|
+
arguments 'x-key': :value
|
47
|
+
|
48
|
+
lazy_queue
|
49
|
+
classic_queue
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
By default Hutch will not configure any `x-queue-type` or `x-queue-mode` optional arguments
|
54
|
+
which is identical to RabbitMQ defaults (a regular classic queue).
|
55
|
+
|
56
|
+
Note that as of RabbitMQ 3.8.2, an omitted `x-queue-type` is [considered to be identical](https://github.com/rabbitmq/rabbitmq-common/issues/341)
|
57
|
+
to `x-queue-type` set to `classic` by RabbitMQ server.
|
58
|
+
|
59
|
+
|
60
|
+
#### Enhancements
|
61
|
+
|
62
|
+
* Exchange type is now configurable via the `` config setting. Supported exchanges must be
|
63
|
+
compatible with topic exchanges (e.g. wrap it). Default value is `"topic"`.
|
64
|
+
|
65
|
+
This feature is limited to topic and delayed message exchange plugins and is mostly
|
66
|
+
useful for forward compatibility.
|
67
|
+
|
68
|
+
Contributed by Michael Bumann.
|
69
|
+
|
70
|
+
GitHub issue: [gocardless/hutch#349](https://github.com/gocardless/hutch/pull/349)
|
71
|
+
|
72
|
+
|
73
|
+
## 0.28.0 (March 17, 2020)
|
2
74
|
|
3
75
|
### Enhancements
|
4
76
|
|
data/LICENSE
CHANGED
data/hutch.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.add_runtime_dependency 'march_hare', '>= 3.0.0'
|
7
7
|
else
|
8
8
|
gem.platform = Gem::Platform::RUBY
|
9
|
-
gem.add_runtime_dependency 'bunny', '>= 2.
|
9
|
+
gem.add_runtime_dependency 'bunny', '>= 2.15', '< 2.16'
|
10
10
|
end
|
11
11
|
gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
|
12
12
|
gem.add_runtime_dependency 'multi_json', '~> 1.14'
|
data/lib/hutch/broker.rb
CHANGED
@@ -122,11 +122,12 @@ module Hutch
|
|
122
122
|
|
123
123
|
def declare_exchange(ch = channel)
|
124
124
|
exchange_name = @config[:mq_exchange]
|
125
|
+
exchange_type = @config[:mq_exchange_type]
|
125
126
|
exchange_options = { durable: true }.merge(@config[:mq_exchange_options])
|
126
127
|
logger.info "using topic exchange '#{exchange_name}'"
|
127
128
|
|
128
129
|
with_bunny_precondition_handler('exchange') do
|
129
|
-
|
130
|
+
Bunny::Exchange.new(ch, exchange_type, exchange_name, exchange_options)
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
data/lib/hutch/config.rb
CHANGED
@@ -49,6 +49,9 @@ module Hutch
|
|
49
49
|
# RabbitMQ Exchange to use for publishing
|
50
50
|
string_setting :mq_exchange, 'hutch'
|
51
51
|
|
52
|
+
# RabbitMQ Exchange type to use for publishing
|
53
|
+
string_setting :mq_exchange_type, 'topic'
|
54
|
+
|
52
55
|
# RabbitMQ vhost to use
|
53
56
|
string_setting :mq_vhost, '/'
|
54
57
|
|
data/lib/hutch/consumer.rb
CHANGED
@@ -29,8 +29,9 @@ module Hutch
|
|
29
29
|
# wants to subscribe to.
|
30
30
|
def consume(*routing_keys)
|
31
31
|
@routing_keys = self.routing_keys.union(routing_keys)
|
32
|
-
|
33
|
-
@
|
32
|
+
# these are opt-in
|
33
|
+
@queue_mode = nil
|
34
|
+
@queue_type = nil
|
34
35
|
end
|
35
36
|
|
36
37
|
attr_reader :queue_mode, :queue_type, :initial_group_size
|
@@ -45,6 +46,11 @@ module Hutch
|
|
45
46
|
@queue_mode = 'lazy'
|
46
47
|
end
|
47
48
|
|
49
|
+
# Explicitly set the queue type to 'classic'
|
50
|
+
def classic_queue
|
51
|
+
@queue_type = 'classic'
|
52
|
+
end
|
53
|
+
|
48
54
|
# Explicitly set the queue type to 'quorum'
|
49
55
|
# @param [Hash] options the options params related to quorum queue
|
50
56
|
# @option options [Integer] :initial_group_size Initial Replication Factor
|
@@ -53,7 +59,8 @@ module Hutch
|
|
53
59
|
@initial_group_size = options[:initial_group_size]
|
54
60
|
end
|
55
61
|
|
56
|
-
#
|
62
|
+
# Configures an optional argument that will be passed when declaring the queue.
|
63
|
+
# Prefer using a policy to this DSL: https://www.rabbitmq.com/parameters.html#policies
|
57
64
|
def arguments(arguments = {})
|
58
65
|
@arguments = arguments
|
59
66
|
end
|
@@ -76,11 +83,11 @@ module Hutch
|
|
76
83
|
# Returns consumer custom arguments.
|
77
84
|
def get_arguments
|
78
85
|
all_arguments = @arguments || {}
|
79
|
-
|
80
|
-
all_arguments['x-queue-
|
81
|
-
if @
|
82
|
-
|
83
|
-
|
86
|
+
|
87
|
+
all_arguments['x-queue-mode'] = @queue_mode if @queue_mode
|
88
|
+
all_arguments['x-queue-type'] = @queue_type if @queue_type
|
89
|
+
all_arguments['x-quorum-initial-group-size'] = @initial_group_size if @initial_group_size
|
90
|
+
|
84
91
|
all_arguments
|
85
92
|
end
|
86
93
|
|
data/lib/hutch/version.rb
CHANGED
data/spec/hutch/consumer_spec.rb
CHANGED
@@ -28,17 +28,30 @@ describe Hutch::Consumer do
|
|
28
28
|
ComplexConsumer
|
29
29
|
end
|
30
30
|
|
31
|
-
let(:
|
32
|
-
unless defined?
|
33
|
-
class
|
31
|
+
let(:consumer_using_quorum_queue) do
|
32
|
+
unless defined? ConsumerUsingQuorumQueue
|
33
|
+
class ConsumerUsingQuorumQueue
|
34
34
|
include Hutch::Consumer
|
35
35
|
consume 'hutch.test1'
|
36
36
|
arguments foo: :bar
|
37
|
-
|
37
|
+
|
38
38
|
quorum_queue
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
ConsumerUsingQuorumQueue
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:consumer_using_classic_queue) do
|
45
|
+
unless defined? ConsumerUsingLazyQueue
|
46
|
+
class ConsumerUsingLazyQueue
|
47
|
+
include Hutch::Consumer
|
48
|
+
consume 'hutch.test1'
|
49
|
+
arguments foo: :bar
|
50
|
+
lazy_queue
|
51
|
+
classic_queue
|
52
|
+
end
|
53
|
+
end
|
54
|
+
ConsumerUsingLazyQueue
|
42
55
|
end
|
43
56
|
|
44
57
|
describe 'module inclusion' do
|
@@ -84,26 +97,33 @@ describe Hutch::Consumer do
|
|
84
97
|
end
|
85
98
|
end
|
86
99
|
|
87
|
-
describe '
|
88
|
-
it 'does not
|
89
|
-
expect(simple_consumer.queue_mode).to eq(
|
100
|
+
describe 'default queue mode' do
|
101
|
+
it 'does not specify any mode by default' do
|
102
|
+
expect(simple_consumer.queue_mode).to eq(nil)
|
103
|
+
expect(simple_consumer.queue_type).to eq(nil)
|
90
104
|
end
|
105
|
+
end
|
91
106
|
|
107
|
+
describe '.lazy_queue' do
|
92
108
|
context 'when queue mode has been set explicitly to lazy' do
|
93
109
|
it 'sets queue mode to lazy' do
|
94
|
-
expect(
|
110
|
+
expect(consumer_using_classic_queue.queue_mode).to eq('lazy')
|
95
111
|
end
|
96
112
|
end
|
97
113
|
end
|
98
114
|
|
99
|
-
describe '.
|
100
|
-
|
101
|
-
|
115
|
+
describe '.classic_queue' do
|
116
|
+
context 'when queue type has been set explicitly to classic' do
|
117
|
+
it 'sets queue type to classic' do
|
118
|
+
expect(consumer_using_classic_queue.queue_type).to eq('classic')
|
119
|
+
end
|
102
120
|
end
|
121
|
+
end
|
103
122
|
|
123
|
+
describe '.quorum_queue' do
|
104
124
|
context 'when queue type has been set explicitly to quorum' do
|
105
125
|
it 'sets queue type to quorum' do
|
106
|
-
expect(
|
126
|
+
expect(consumer_using_quorum_queue.queue_type).to eq('quorum')
|
107
127
|
end
|
108
128
|
|
109
129
|
it 'accepts initial group size as an option' do
|
@@ -125,34 +145,26 @@ describe Hutch::Consumer do
|
|
125
145
|
end
|
126
146
|
|
127
147
|
describe '.get_arguments' do
|
128
|
-
|
129
148
|
context 'when defined' do
|
130
149
|
it { expect(complex_consumer.get_arguments).to include(foo: :bar) }
|
131
150
|
end
|
132
151
|
|
133
|
-
context 'when not defined' do
|
134
|
-
it 'has the default values for queue custom options' do
|
135
|
-
expect(simple_consumer.get_arguments).to have_key('x-queue-mode')
|
136
|
-
.and have_key('x-queue-type')
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
152
|
context 'when queue is lazy' do
|
141
153
|
it 'has the x-queue-mode argument set to lazy' do
|
142
|
-
expect(
|
154
|
+
expect(consumer_using_classic_queue.get_arguments['x-queue-mode'])
|
143
155
|
.to eq('lazy')
|
144
156
|
end
|
145
157
|
end
|
146
158
|
|
147
159
|
context "when queue's type is quorum" do
|
148
|
-
let(:arguments) {
|
160
|
+
let(:arguments) { consumer_using_quorum_queue.get_arguments }
|
149
161
|
it 'has the x-queue-type argument set to quorum' do
|
150
162
|
expect(arguments['x-queue-type']).to eq('quorum')
|
151
163
|
expect(arguments).to_not have_key('x-quorum-initial-group-size')
|
152
164
|
end
|
153
165
|
|
154
166
|
it 'has the x-quorum-initial-group-size argument set to quorum' do
|
155
|
-
|
167
|
+
consumer_using_quorum_queue.quorum_queue(initial_group_size: 5)
|
156
168
|
expect(arguments['x-queue-type']).to eq('quorum')
|
157
169
|
expect(arguments['x-quorum-initial-group-size']).to eq(5)
|
158
170
|
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Marr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-08 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: '2.
|
19
|
+
version: '2.15'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2.16'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2.
|
29
|
+
version: '2.15'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.16'
|
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
181
|
+
rubygems_version: 3.1.2
|
182
182
|
signing_key:
|
183
183
|
specification_version: 4
|
184
184
|
summary: Easy inter-service communication using RabbitMQ.
|