rabbit_carrots 1.2.0 → 1.2.1
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 +11 -0
- data/Gemfile.lock +4 -4
- data/README.md +14 -1
- data/lib/rabbit_carrots/core.rb +16 -4
- data/lib/rabbit_carrots/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d158e9a122e5fe4e003a3b4c132aee2560940fe219ab12b029815130f7f55c6
|
|
4
|
+
data.tar.gz: ac719d756751b3583716136e7014d89348df7a7ca94ccf4e03e68d65aab6e2cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f83a2c8a8d45e95a081804ebd406adb3655f9372608bc51548f7ee7684c3996b9e7ec6ad2936a71827e74f9a4db69af78cb5bb570d86dc7c06e125ba04dd6fbc
|
|
7
|
+
data.tar.gz: 81197e0c9027daa4f07b5180eae94f0bdded351d208d9bc20759dcf4ce3e026b597432aea8749df4dc0aa2fcf3d2baa17cfe4e165d14a88c78d3322ca087ffa1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- `passive_exchange: true` on a routing key mapping binds to an existing
|
|
6
|
+
exchange without declaring it, so the user needs no `configure` permission on
|
|
7
|
+
an exchange owned by another service.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Requires `bunny >= 3.3`, the first version that leaves passive declarations
|
|
12
|
+
out of topology recovery.
|
|
13
|
+
|
|
3
14
|
## [1.2.0] - 2026-09-22
|
|
4
15
|
|
|
5
16
|
### Fixed
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rabbit_carrots (1.2.
|
|
5
|
-
bunny (>= 3.
|
|
4
|
+
rabbit_carrots (1.2.1)
|
|
5
|
+
bunny (>= 3.3)
|
|
6
6
|
connection_pool (>= 2.4)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activesupport (8.1.
|
|
11
|
+
activesupport (8.1.4.1)
|
|
12
12
|
base64
|
|
13
13
|
bigdecimal
|
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
@@ -50,7 +50,7 @@ GEM
|
|
|
50
50
|
racc
|
|
51
51
|
prism (1.9.0)
|
|
52
52
|
racc (1.8.1)
|
|
53
|
-
rack (3.2.
|
|
53
|
+
rack (3.2.8)
|
|
54
54
|
rainbow (3.1.1)
|
|
55
55
|
rake (13.4.2)
|
|
56
56
|
rbtree (0.4.7)
|
data/README.md
CHANGED
|
@@ -44,7 +44,9 @@ RabbitCarrots.configure do |c|
|
|
|
44
44
|
c.orm = :activerecord || :mongoid
|
|
45
45
|
c.routing_key_mappings = [
|
|
46
46
|
{ routing_keys: ['RK1', 'RK2'], queue: 'QUEUE_NAME', handler: 'CLASS HANDLER IN STRING' },
|
|
47
|
-
{ routing_keys: ['RK1', 'RK2'], queue: 'QUEUE_NAME', handler: 'CLASS HANDLER IN STRING' }
|
|
47
|
+
{ routing_keys: ['RK1', 'RK2'], queue: 'QUEUE_NAME', handler: 'CLASS HANDLER IN STRING' },
|
|
48
|
+
{ routing_keys: ['RK1'], queue: 'QUEUE_NAME', handler: 'CLASS HANDLER IN STRING',
|
|
49
|
+
exchange_name: 'ANOTHER_SERVICES_EXCHANGE', passive_exchange: true }
|
|
48
50
|
]
|
|
49
51
|
end
|
|
50
52
|
|
|
@@ -84,6 +86,17 @@ takes every consumer on it with it. The process stays up and stops consuming.
|
|
|
84
86
|
If the durability is wrong, the service now says so and refuses to start rather
|
|
85
87
|
than consuming from a channel that will not survive its first reconnect.
|
|
86
88
|
|
|
89
|
+
### Consuming from an exchange you don't own
|
|
90
|
+
|
|
91
|
+
By default each exchange is declared, which needs `configure` permission on it.
|
|
92
|
+
To bind to an exchange another service owns without that permission, set
|
|
93
|
+
`passive_exchange: true` on the mapping. The exchange is then only checked for
|
|
94
|
+
existence; the user needs `read` on it to bind, and nothing else.
|
|
95
|
+
|
|
96
|
+
If the exchange does not exist, the consumer fails to start and says so. Passive
|
|
97
|
+
declarations are left out of Bunny's topology recovery (Bunny >= 3.3), so a
|
|
98
|
+
reconnect does not try to declare the exchange either.
|
|
99
|
+
|
|
87
100
|
### Health and restarts
|
|
88
101
|
|
|
89
102
|
A consumer subscribes and then does its work on Bunny's own threads, so the
|
data/lib/rabbit_carrots/core.rb
CHANGED
|
@@ -47,6 +47,7 @@ module RabbitCarrots
|
|
|
47
47
|
routing_keys: channel[:routing_keys],
|
|
48
48
|
queue_arguments: channel[:arguments],
|
|
49
49
|
exchange_name: channel[:exchange_name],
|
|
50
|
+
passive_exchange: channel[:passive_exchange],
|
|
50
51
|
kill_to_restart_on_standard_error:
|
|
51
52
|
)
|
|
52
53
|
end
|
|
@@ -87,10 +88,10 @@ module RabbitCarrots
|
|
|
87
88
|
@healthy
|
|
88
89
|
end
|
|
89
90
|
|
|
90
|
-
def run_task(queue_name:, handler_class:, routing_keys:, queue_arguments: {}, exchange_name: nil, kill_to_restart_on_standard_error: false)
|
|
91
|
+
def run_task(queue_name:, handler_class:, routing_keys:, queue_arguments: {}, exchange_name: nil, passive_exchange: false, kill_to_restart_on_standard_error: false) # rubocop:disable Metrics/ParameterLists
|
|
91
92
|
channel = RabbitCarrots::Connection.instance.create_channel
|
|
92
93
|
exchange_name ||= RabbitCarrots.configuration.rabbitmq_exchange_name
|
|
93
|
-
exchange = declare_exchange(channel, exchange_name)
|
|
94
|
+
exchange = declare_exchange(channel, exchange_name, passive: passive_exchange)
|
|
94
95
|
|
|
95
96
|
logger.info "Listening on QUEUE: #{queue_name} for ROUTING KEYS: #{routing_keys}"
|
|
96
97
|
queue = channel.queue(queue_name, durable: true, arguments: queue_arguments)
|
|
@@ -146,9 +147,20 @@ module RabbitCarrots
|
|
|
146
147
|
RabbitCarrots::EventHandlers::Errors::PlaceholderError
|
|
147
148
|
end
|
|
148
149
|
|
|
149
|
-
#
|
|
150
|
-
|
|
150
|
+
# A passive declaration only checks that an exchange owned by another
|
|
151
|
+
# service exists, so it needs no `configure` permission on it. Bunny >= 3.3
|
|
152
|
+
# leaves passive declarations out of topology recovery; older versions
|
|
153
|
+
# recorded them and replayed a durability mismatch on every reconnect.
|
|
154
|
+
def declare_exchange(channel, exchange_name, passive: false)
|
|
155
|
+
return channel.exchange(exchange_name, type: :topic, durable: exchange_durable?, passive: true) if passive
|
|
156
|
+
|
|
151
157
|
channel.topic(exchange_name, durable: exchange_durable?)
|
|
158
|
+
rescue Bunny::NotFound => e
|
|
159
|
+
logger.error(
|
|
160
|
+
"Exchange '#{exchange_name}' does not exist. With `passive_exchange: true` it is not declared " \
|
|
161
|
+
"here and must be created by the service that owns it. Error: #{e.message}"
|
|
162
|
+
)
|
|
163
|
+
raise
|
|
152
164
|
rescue Bunny::PreconditionFailed => e
|
|
153
165
|
logger.error(
|
|
154
166
|
"Exchange '#{exchange_name}' exists on the broker with a different durability than the one " \
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rabbit_carrots
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brusk Awat
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09
|
|
11
|
+
date: 2026-11-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bunny
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '3.
|
|
19
|
+
version: '3.3'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '3.
|
|
26
|
+
version: '3.3'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: connection_pool
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|