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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 587ca7c6e7515a0efcf8999a5ad3bfc1ef186a701a758260f68abb528641b7cd
4
- data.tar.gz: 7f4353919efb856a7ef9af3dc71e7d2024aaa85c1183da3a191bbbf2c22a8492
3
+ metadata.gz: 626b85f02b69ee2113376ff382173fd124cdcae1bdc404f0681874e76a80310e
4
+ data.tar.gz: 3d1d6a2cd275b1c2d72d4842841ad90f70145cabe6800ff3860b206aebf0308e
5
5
  SHA512:
6
- metadata.gz: 9c00226f20383fc7ec3503197783a48e0d8f153dd7e45ea7d89dda7631f2e527f71b6d15182be677d24818e1ce1cfcf6766765ad6a0e67b753b76cc145b46782
7
- data.tar.gz: 530af1729a20c10d555bac21529d18c94cb07b1957ce2b6c5386adede9e400c7f7f400491c7c716378fd4fc8d8a955d2537e956dc6d6994aab5fc3cd2f2b5970
6
+ metadata.gz: c1b0c80bf6362b0cfbc6f54b3257c74549c6d927fbae3bcaecb50aeb4ed0f28e01466a6a3013ce9175f55eb481b2e9378f89954edcc1453753da00b76873c766
7
+ data.tar.gz: 4c346421c5c1fa49440866b56486cc75d68c3eed8c3014ae2f51e2643f40a59b084634248b52d32965b65f692d1560250a8f5add30c4b75b2f541c895574aa26
@@ -11,9 +11,10 @@ before_script:
11
11
  - "./bin/ci/before_build.sh"
12
12
  matrix:
13
13
  include:
14
- - rvm: "2.6.4"
15
- - rvm: "2.5.6"
16
- - rvm: "2.4.7"
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"
@@ -1,4 +1,76 @@
1
- ## 0.28.0 (under development)
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
@@ -1,4 +1,5 @@
1
1
  Copyright (c) 2013-2016 GoCardless
2
+ Copyright (c) 2016-2020 Hutch contributors
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person
4
5
  obtaining a copy of this software and associated documentation
@@ -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.14', '< 2.16'
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'
@@ -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
- ch.topic(exchange_name, exchange_options)
130
+ Bunny::Exchange.new(ch, exchange_type, exchange_name, exchange_options)
130
131
  end
131
132
  end
132
133
 
@@ -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
 
@@ -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
- @queue_mode = 'default'
33
- @queue_type = 'classic'
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
- # Allow to specify custom arguments that will be passed when creating the queue.
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
- all_arguments['x-queue-mode'] = @queue_mode
80
- all_arguments['x-queue-type'] = @queue_type
81
- if @initial_group_size
82
- all_arguments['x-quorum-initial-group-size'] = @initial_group_size
83
- end
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
 
@@ -1,3 +1,3 @@
1
1
  module Hutch
2
- VERSION = '0.28.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -28,17 +28,30 @@ describe Hutch::Consumer do
28
28
  ComplexConsumer
29
29
  end
30
30
 
31
- let(:consumer_with_custom_queue_options) do
32
- unless defined? ConsumerWithCustomQueueOptions
33
- class ConsumerWithCustomQueueOptions
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
- lazy_queue
37
+
38
38
  quorum_queue
39
39
  end
40
40
  end
41
- ConsumerWithCustomQueueOptions
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 '.lazy_queue' do
88
- it 'does not use lazy mode by default' do
89
- expect(simple_consumer.queue_mode).to eq('default')
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(consumer_with_custom_queue_options.queue_mode).to eq('lazy')
110
+ expect(consumer_using_classic_queue.queue_mode).to eq('lazy')
95
111
  end
96
112
  end
97
113
  end
98
114
 
99
- describe '.quorum_queue' do
100
- it 'does not have quorum type by default' do
101
- expect(simple_consumer.queue_type).to eq('classic')
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(consumer_with_custom_queue_options.queue_type).to eq('quorum')
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(consumer_with_custom_queue_options.get_arguments['x-queue-mode'])
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) { consumer_with_custom_queue_options.get_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
- consumer_with_custom_queue_options.quorum_queue(initial_group_size: 5)
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.28.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-03-17 00:00:00.000000000 Z
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.14'
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.14'
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.0.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.