async-rabbitmq 0.8.1 → 0.9.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 +247 -0
- data/README.md +44 -9
- data/lib/async_rabbitmq/channel.rb +506 -78
- data/lib/async_rabbitmq/cluster.rb +53 -20
- data/lib/async_rabbitmq/frame_io.rb +43 -19
- data/lib/async_rabbitmq/log.rb +4 -1
- data/lib/async_rabbitmq/logging.rb +141 -0
- data/lib/async_rabbitmq/notifier.rb +5 -2
- data/lib/async_rabbitmq/sasl.rb +16 -3
- data/lib/async_rabbitmq/session.rb +302 -85
- data/lib/async_rabbitmq/version.rb +1 -1
- data/lib/async_rabbitmq.rb +22 -0
- metadata +32 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c642d121d7162e36f2d796694354aa8d4d883b884b783d84a22badd95bff7af0
|
|
4
|
+
data.tar.gz: bf02457f00c3e1e528ff8972ceb8c3a8d8be6723fba64bd129c8252b6681b3f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21cc0a3397a9057ceb7610a0ab46461d62e5ce7492cc48539a9bdf4585e7f4eebd926e4656c9f8481853d0bb4779a6cdcc32c0860aff5e66a8eece93a650c93b
|
|
7
|
+
data.tar.gz: c8d185e7f838d9c4ed545992bb14d9ab37c6e562fdf7a64231d7036c4a5e2e0d412bef72d8ef87c928417dd49b70e77b560cc11b6eb5e20567b59049511ea9b5
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,253 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.9.0] - 2026-11-24
|
|
6
|
+
|
|
7
|
+
A reliability release: three waves of fixes from a full review of 0.8.1, a broadened recovery
|
|
8
|
+
test suite that found one more, and the first steps of moving the internals onto the async
|
|
9
|
+
ecosystem's own primitives. No public method was removed or renamed.
|
|
10
|
+
|
|
11
|
+
### Upgrading from 0.8
|
|
12
|
+
|
|
13
|
+
- **Dependencies:** `async` `~> 2.29` (was `~> 2.0`), and two new runtime dependencies,
|
|
14
|
+
`io-endpoint` `~> 0.19` (which needs the `openssl` gem `>= 3.3`, shipped with Ruby 3.4) and
|
|
15
|
+
`console` `~> 1.29` (already loaded by `async`).
|
|
16
|
+
- **Logging** goes through Console by default, capped at warnings by the new
|
|
17
|
+
`AsyncRabbitMQ.log_level`, so the default volume is unchanged. `logger:` still takes
|
|
18
|
+
`Rails.logger`, a stdlib `Logger` or `AsyncRabbitMQ::Log`. `logger: nil` now silences a session,
|
|
19
|
+
and **`Cluster.new(logger: nil)` is now silent** where it used to fall back to the default;
|
|
20
|
+
leave `logger:` out to get the default. A value that is not a logger raises `ArgumentError`.
|
|
21
|
+
- **`connect` raises `NotOpenError`** while the session is recovering or another connect is in
|
|
22
|
+
flight; close the session first to force a fresh connection.
|
|
23
|
+
- **SASL prefers PLAIN over EXTERNAL** when a password is given and no client certificate is
|
|
24
|
+
configured; certificate material keeps EXTERNAL first, and `auth_mechanism:` still forces
|
|
25
|
+
either.
|
|
26
|
+
- **Sockets use `TCP_NODELAY`.**
|
|
27
|
+
- **`update_secret` keeps the new secret on a timeout** for reconnects, with a warning, rather
|
|
28
|
+
than discarding it.
|
|
29
|
+
- **New events and payload keys:** `recovery.topology_incomplete`, and `topology_complete:` on
|
|
30
|
+
`recovery.succeeded`.
|
|
31
|
+
|
|
32
|
+
### Tests
|
|
33
|
+
|
|
34
|
+
- Recovery coverage broadened beyond the clean-FIN disconnect the suite had tested almost
|
|
35
|
+
exclusively. New toxiproxy helpers (`blackhole` for a silent half-open connection via the
|
|
36
|
+
timeout toxic, `force_close_connection!` via the management API) and coverage for: the
|
|
37
|
+
heartbeat watchdog detecting a black-holed peer with no FIN/RST (the 15-minute-hang case the
|
|
38
|
+
watchdog exists for, previously never the detector in any test); broker-initiated
|
|
39
|
+
`connection.close` from an operator force-close and from a vhost deleted under a live session
|
|
40
|
+
(handshake refused on every retry); recovery over TLS (the `rabbitmq_tls` toxiproxy proxy was
|
|
41
|
+
provisioned but unused); exchange-to-exchange binding recovery; transactional-mode re-selection
|
|
42
|
+
across a drop; the cluster `:drop` policy handing a lost node's unconfirmed messages to a
|
|
43
|
+
four-argument `on_node_down`; four flaps in a row leaving exactly one consumer and no
|
|
44
|
+
duplicates; a publisher parked on the `connection.blocked` gate when the broker dies; a broker
|
|
45
|
+
that accepts TCP but never answers; `close` racing an outage; reconnecting a session after
|
|
46
|
+
recovery exhausts its attempts; credentials revoked during an outage abandoning recovery with
|
|
47
|
+
`reason: :authentication_failed`; and `recovery.succeeded` carrying `topology_complete: true`.
|
|
48
|
+
- Degraded-transport coverage: a multi-frame message delivered in tiny TCP fragments (slicer
|
|
49
|
+
toxic) reassembles intact, and a connection cut mid-body (limit_data toxic) never hands a
|
|
50
|
+
truncated body to a handler and is redelivered whole after recovery. The incomplete-replay
|
|
51
|
+
reporting path is now also covered end to end — real drop, reopen and replay loop, with one
|
|
52
|
+
declare timing out — asserting `recovery.topology_incomplete` and `topology_complete: false`.
|
|
53
|
+
- Cluster recovery edges: all nodes down at once leaving the cluster neither open nor closed and
|
|
54
|
+
`open_channel` raising until one returns; a node recovered through two outage cycles in a row;
|
|
55
|
+
`:drop` keeping a node's durable topology recorded while forgetting its transient queues; and a
|
|
56
|
+
raising `on_node_down` policy contained so the node still recovers and the callback still fires.
|
|
57
|
+
- RST-vs-FIN coverage (new `69_rst_and_teardown`, `reset_peer` / `slow_close` toxics): a peer
|
|
58
|
+
RESET mid-session recovered and detected as a transport error rather than by the watchdog, a
|
|
59
|
+
RESET during the handshake failing the connect promptly, and `close` staying bounded against a
|
|
60
|
+
peer lingering in half-close.
|
|
61
|
+
- Multi-channel recovery: three channels with distinct state (confirm-tracking + prefetch, tx,
|
|
62
|
+
plain) restored in one pass with no cross-talk.
|
|
63
|
+
- The server-named-rename replay test (added pending in this cycle when it exposed the bug) now
|
|
64
|
+
runs active against the fix below.
|
|
65
|
+
|
|
66
|
+
### Fixed
|
|
67
|
+
|
|
68
|
+
- An unconfirmed publish follows a server-named queue's rename into the replay. Recovery
|
|
69
|
+
re-declares a server-named queue under a new broker-generated name and renamed the registry,
|
|
70
|
+
the bindings and the consumers - but not the pending confirms, whose kept pre-encoded frames
|
|
71
|
+
carry the routing key inside the Basic::Publish method frame. A publish left unconfirmed at
|
|
72
|
+
the drop was therefore replayed to the OLD name through the default exchange: unroutable,
|
|
73
|
+
silently dropped, the exact loss confirms exist to prevent - and the RPC-reply pattern
|
|
74
|
+
(publish to your own server-named queue) hits it on every recovery that renames. The affected
|
|
75
|
+
entries are now rewritten under the new name before the replay runs. `reply_to` follows the
|
|
76
|
+
rename too, whatever the exchange - the RPC request pattern names the publisher's own
|
|
77
|
+
server-named queue there, and a replayed request carrying the old name sends the responder's
|
|
78
|
+
answer to a dead queue. Routing keys on named exchanges are left alone: there the key is the
|
|
79
|
+
caller's semantics, and the renamed binding already carries it to the right queue.
|
|
80
|
+
- The replay re-encodes each message from the payload and context the entry already keeps,
|
|
81
|
+
rather than re-sending the bytes recorded at publish time, so it also splits frames at the
|
|
82
|
+
frame_max the reconnect actually negotiated. Replaying stale frames encoded for a larger
|
|
83
|
+
frame_max (a failover to a differently configured node) was a 501 FRAME_ERROR that killed each
|
|
84
|
+
fresh connection in turn. New publishes after such a failover use the renegotiated size too.
|
|
85
|
+
- The payload kept with a pending confirm is snapshotted at publish time. It was held by
|
|
86
|
+
reference, so a caller that reused or mutated its buffer after publishing could corrupt what a
|
|
87
|
+
replay re-encoded or what `unconfirmed_messages` handed to a `Cluster` `on_node_down` callback.
|
|
88
|
+
Frozen strings skip the copy.
|
|
89
|
+
- A topology replay that stops early is reported instead of being mistaken for success. A hard
|
|
90
|
+
failure mid-replay - an RPC timeout from a broker that stopped answering, where each remaining
|
|
91
|
+
entity would cost its own full timeout - still stops the replay, but now emits a
|
|
92
|
+
`recovery.topology_incomplete` event naming the failed entity and how many were skipped, and
|
|
93
|
+
`recovery.succeeded` carries `topology_complete: false`. Previously the abort was one log line
|
|
94
|
+
and recovery looked fully successful with an arbitrary suffix of the topology missing.
|
|
95
|
+
- IPv6 works through `Session.from_uri`, `Cluster.from_uri` and `addresses:`. These flattened
|
|
96
|
+
every node to a `"host:port"` string and split it back on the first colon, which mangled an
|
|
97
|
+
IPv6 literal into nonsense (`"[::1]:5672"` became host `"["`, port 0). URI lists now carry
|
|
98
|
+
`[host, port]` pairs end-to-end, and `addresses:` accepts bracketed literals (`"[::1]:5672"`),
|
|
99
|
+
bare literals (`"::1"`, host only) and `[host, port]` pairs alongside the usual strings.
|
|
100
|
+
`host:` and `hosts:` already worked.
|
|
101
|
+
- Concurrent `update_secret` calls no longer clobber each other's reply. Each call destroyed the
|
|
102
|
+
other's registration, both replies were dropped, both calls timed out - and `@password` was
|
|
103
|
+
never updated although the broker had accepted the new secret, so the next reconnect
|
|
104
|
+
authenticated with the stale one and recovery was abandoned for good. Calls are serialised
|
|
105
|
+
now. On a timeout the new secret is also kept for reconnects, with a warning: the reply, not
|
|
106
|
+
the request, may be what got lost, and with OAuth rotation the old token is the one about to
|
|
107
|
+
expire.
|
|
108
|
+
- `close` no longer strands a channel when the Close RPC itself fails. A close-ok that never
|
|
109
|
+
arrived left close raising out of a channel its own RPC-timeout resync had just reopened - the
|
|
110
|
+
user got an exception and a live channel they believed closed. close now retries once on the
|
|
111
|
+
resynced channel, and raises only if the broker will not answer that either (the channel is
|
|
112
|
+
then alive and usable, and its id is not recycled under a broker that still considers it
|
|
113
|
+
open). A connection lost mid-close drops the channel so recovery cannot resurrect something
|
|
114
|
+
the user asked to be rid of.
|
|
115
|
+
|
|
116
|
+
- A connection lost while a channel is resynchronising after an RPC timeout no longer kills the
|
|
117
|
+
channel for good. The resync was parked waiting for a channel.close-ok that the dropped
|
|
118
|
+
connection would never deliver; it waited out its whole timeout, then reopened against a
|
|
119
|
+
session that was no longer open, which raised, dropped the channel from the session and
|
|
120
|
+
stranded its consumers - with `@consumers` already cleared, recovery had nothing left to
|
|
121
|
+
restore. The resync is now woken by the connection loss, sees the channel is recovering and
|
|
122
|
+
hands the reopen to the recovery loop, which brings the channel and its consumers back. This
|
|
123
|
+
also closes the related hang where a recovery that won the race had its channel.open-ok
|
|
124
|
+
discarded by the resync's own frame filter.
|
|
125
|
+
- `close` on a channel that is mid-resync waits for the resync to settle and then closes the
|
|
126
|
+
live channel, instead of falling through and returning as though it had closed one that was in
|
|
127
|
+
fact still open and consuming.
|
|
128
|
+
- An RPC timeout no longer leaks the old dispatch fiber. The resync swapped the channel's frame
|
|
129
|
+
queue without stopping the dispatch loop bound to the old one, which then parked on an orphaned
|
|
130
|
+
queue for the life of the reactor - one leaked fiber per RPC-timeout resync in a long-lived
|
|
131
|
+
process. The reopen path now stops the old loop first, as every other teardown already did.
|
|
132
|
+
- One consumer whose queue is gone no longer takes every other consumer on the channel down with
|
|
133
|
+
it during recovery. Re-subscribing a consumer to a deleted queue draws a 404 that closes the
|
|
134
|
+
whole channel, cancelling the consumers already restored on it; the old code then failed the
|
|
135
|
+
rest with `NotOpenError` and left the channel closed and dropped from the session, while
|
|
136
|
+
recovery still reported success. Re-registration now works in passes: the rejected consumer is
|
|
137
|
+
dropped (with a `consumer.recovery_failed` event), the channel reopened, and the survivors
|
|
138
|
+
re-subscribed. Only a broker rejection of a specific consumer drops it — a connection lost
|
|
139
|
+
again mid-re-registration leaves every consumer in place for the next recovery cycle to
|
|
140
|
+
restore, rather than mistaking the outage for a dead queue and forgetting them. On a channel
|
|
141
|
+
with publisher confirms, that reopen replays the unconfirmed messages and resets the confirm
|
|
142
|
+
numbering as `Channel#reopen` does, so later acks resolve the right publishes. A consumer is
|
|
143
|
+
only ever dropped for a close the broker made over its own `basic.consume` - `channel.close`
|
|
144
|
+
names the method at fault. A replayed message the broker refuses (sent to an exchange that
|
|
145
|
+
is gone) blames no consumer: the channel is reopened without replaying, and the unconfirmed
|
|
146
|
+
messages are reported to the publisher as nacked, since their fate is unknown and replaying
|
|
147
|
+
them would close the channel every time. A second such close gives the channel up instead of
|
|
148
|
+
looping, and a connection lost meanwhile leaves everything for the next recovery.
|
|
149
|
+
- `Cluster#close` called from another fiber while `connect` is still waiting for its nodes no
|
|
150
|
+
longer hangs that connect forever. The connect waited on a condition only the node supervisors
|
|
151
|
+
signalled, and close stopped the supervisors before they reported; it now wakes the connect,
|
|
152
|
+
which returns with a `NotOpenError`.
|
|
153
|
+
- A `Cluster` `on_connection_lost` callback that raises no longer suppresses `on_node_down` -
|
|
154
|
+
which, under the `:drop` policy, is the only chance to see the messages the lost node never
|
|
155
|
+
confirmed. Each callback is now isolated.
|
|
156
|
+
- A publisher parked on a full write queue is released when the connection stops. It was woken
|
|
157
|
+
only by the writer draining the queue, and the writer had just been cancelled - so it stayed
|
|
158
|
+
parked forever, holding the channel's publish semaphore, and every publish on that channel
|
|
159
|
+
after recovery queued behind it. A full write queue at disconnect is the likely case: TCP
|
|
160
|
+
backpressure is how a partition presents itself to a writer. The queue is closed on stop; a
|
|
161
|
+
write that loses the race is discarded, which is what already happened to every write that
|
|
162
|
+
reached the dead queue. Requires async >= 2.24 (where `Async::Queue#close` appeared).
|
|
163
|
+
- A channel close releases every parked waiter, whichever way the close came. The broker
|
|
164
|
+
closing the channel (a 404 publish under confirms is the canonical case) and the user calling
|
|
165
|
+
`close` each woke the RPC caller but not a fiber in `wait_for_confirms` - which, with no
|
|
166
|
+
timeout given (the default), parked forever on an ack that can never arrive - nor a publisher
|
|
167
|
+
parked on an outstanding-confirm slot, which stalled `rpc_timeout` seconds holding the publish
|
|
168
|
+
semaphore. All teardown paths now release all waiters, and `wait_for_confirms` raises the
|
|
169
|
+
error it was handed - the channel's actual fate - rather than a generic disconnect message.
|
|
170
|
+
- `connect` refuses to run while the session is recovering or already connecting. A connect
|
|
171
|
+
racing the recovery loop fought it for the connection, and when that connect failed - the
|
|
172
|
+
broker being down is why recovery was running - its cleanup cancelled the recovery task and
|
|
173
|
+
marked the session closed, stranding every recovering channel's parked fibers permanently:
|
|
174
|
+
`close` was by then a no-op and a later `connect` never reopens recovering channels. Close the
|
|
175
|
+
session first to force a fresh connection.
|
|
176
|
+
- SASL negotiation no longer auto-selects EXTERNAL over PLAIN. EXTERNAL authenticates by TLS
|
|
177
|
+
certificate and sends no credentials, so picking it for a caller who supplied a password
|
|
178
|
+
silently discarded that password - refused credentials against any broker whose
|
|
179
|
+
`auth_mechanisms` advertises EXTERNAL, despite the password being valid. PLAIN now wins when
|
|
180
|
+
a password is given and no client certificate is configured, as in Bunny and the Java client.
|
|
181
|
+
Certificate material (`tls_cert:` / `tls_context:`) keeps EXTERNAL first - the certificate is
|
|
182
|
+
the identity the caller configured on purpose, where the password is usually the untouched
|
|
183
|
+
guest default - and `auth_mechanism:` still forces either outright.
|
|
184
|
+
- CI runs the unit specs, which were never exercised there, and the job times out after 30
|
|
185
|
+
minutes instead of holding a runner for six hours when a toxiproxy spec wedges.
|
|
186
|
+
|
|
187
|
+
### Changed
|
|
188
|
+
|
|
189
|
+
- Every one-shot wait is an `Async::Promise` now, instead of a hand-rolled lazily-created
|
|
190
|
+
`Async::Condition`: the latch fibers park on through recovery and resync, the reply slot of
|
|
191
|
+
every synchronous operation, `update_secret`'s reply, and the `connection.blocked` gate. A
|
|
192
|
+
promise's resolution is sticky, which removes a whole class of lost-wakeup windows the
|
|
193
|
+
condition code had to defend against site by site - a waiter arriving after the resolution gets
|
|
194
|
+
the same answer instead of parking on a signal already spent, and a reply dispatched while the
|
|
195
|
+
requester is still parked inside its own write (a full write queue yields there) is kept for
|
|
196
|
+
it, where before it was discarded and the requester timed out into a needless channel resync.
|
|
197
|
+
Reply slots are registered before the request is written for the same reason. The recovery
|
|
198
|
+
retry sleep is poked by an `Async::Notification`, its purpose-built primitive. Raises the
|
|
199
|
+
`async` requirement to `~> 2.29`, where `Async::Promise` appeared (alongside thread-safe
|
|
200
|
+
`Condition`/`Queue`); `Async::Variable` was skipped as deprecated.
|
|
201
|
+
- A session's infrastructure tasks - frame reader and writer, heartbeat, channel-0 monitor,
|
|
202
|
+
recovery loop, channel dispatch loops and cancelled-consumer reconcilers - are owned by a
|
|
203
|
+
per-connection-lifecycle `Async::Barrier`. `close`, and the cleanup after a failed `connect`,
|
|
204
|
+
end by cancelling it, so anything the targeted teardown missed is stopped too: the leaked
|
|
205
|
+
dispatch fiber a resync once left behind is now impossible by construction rather than fixed
|
|
206
|
+
case by case. Spawning is refused once the session is closed, so nothing can quietly start a
|
|
207
|
+
fresh barrier on a closed session. Consumer workers and application callbacks stay outside it
|
|
208
|
+
on purpose: a graceful close still lets workers finish the backlog they hold, and a callback
|
|
209
|
+
in flight is the application's to finish. `Cluster`'s per-node supervisors share one barrier
|
|
210
|
+
the same way.
|
|
211
|
+
- Connections are opened through `io-endpoint`, the connection layer `async-http` and the rest of
|
|
212
|
+
the socketry stack use, replacing the hand-built `TCPSocket` + `OpenSSL::SSL::SSLSocket` code.
|
|
213
|
+
The endpoint resolves the host and tries its addresses in order, within the one
|
|
214
|
+
`connect_timeout` (as `TCPSocket.new` did under a fiber scheduler, where it skips Happy
|
|
215
|
+
Eyeballs). For TLS, its socket wrapper sets `sync_close` (without it, closing the TLS socket
|
|
216
|
+
left the TCP socket open until GC, one leaked connection per `amqps` reconnect) and its
|
|
217
|
+
hostname drives SNI and certificate verification. The handshake itself still runs in this
|
|
218
|
+
client, because the endpoint's own `connect` only closes the socket on a `StandardError`: a
|
|
219
|
+
handshake cut short by cancellation (`close` stopping a recovery mid-handshake) would leak
|
|
220
|
+
the TCP socket. Here any exit but success closes it. `TCP_USER_TIMEOUT` is still applied to
|
|
221
|
+
the TCP socket underneath, TLS included. New runtime dependency: `io-endpoint ~> 0.19`.
|
|
222
|
+
- The client logs through [Console](https://github.com/socketry/console) by default, like the
|
|
223
|
+
rest of the async stack, instead of `AsyncRabbitMQ::Log`. Every log call now names the object
|
|
224
|
+
that logged it - `@logger.warn(self, message)`, Console's own shape - so Console's controls
|
|
225
|
+
work per component: `CONSOLE_LEVEL=debug` for everything, or
|
|
226
|
+
`Console.logger.filter(AsyncRabbitMQ::Channel, Console::Logger::DEBUG)` for channels alone.
|
|
227
|
+
Console's logger is per fiber; one set with `Console.logger =` before `connect` reaches every
|
|
228
|
+
background task the session starts. Each session gets its own adapter object, so patching one
|
|
229
|
+
session's logger can never reach another.
|
|
230
|
+
- `AsyncRabbitMQ.log_level` caps what this gem logs at all, whatever logger a session was given:
|
|
231
|
+
`:debug`, `:info`, `:warn` (the default), `:error`, `:fatal` or `:off`, also settable with the
|
|
232
|
+
`ASYNC_RABBITMQ_LOG_LEVEL` environment variable. It is checked before a message reaches the
|
|
233
|
+
logger, so an application running Console or Rails' logger at info is not flooded with this
|
|
234
|
+
client's info and debug lines unless it raises the level, and the default volume stays
|
|
235
|
+
warnings and errors, as it was. Process-wide and read on every call; an unknown level is
|
|
236
|
+
refused when set.
|
|
237
|
+
- `logger:` still takes anything with `debug`/`info`/`warn`/`error` - `Rails.logger`, a stdlib
|
|
238
|
+
`Logger`, `AsyncRabbitMQ::Log` - and still sends that session's messages there alone; such a
|
|
239
|
+
logger is wrapped in a small adapter that drops the subject. New: `logger: nil` discards
|
|
240
|
+
everything, and `logger: Console.logger` (or any `Console::Logger`) is used as given. A value
|
|
241
|
+
that is not a logger is refused with an `ArgumentError` saying what is accepted. `console` is
|
|
242
|
+
now a declared dependency; `async` already required it.
|
|
243
|
+
- **`Cluster.new(logger: nil)` now means silent.** It used to fall back to the default logger,
|
|
244
|
+
which printed node failures such as refused credentials and unreachable nodes; it now
|
|
245
|
+
discards everything, the same as `nil` on a `Session`. An application that passed `nil` to
|
|
246
|
+
mean "default" should leave `logger:` out instead.
|
|
247
|
+
- Sockets are opened with `TCP_NODELAY`, io-endpoint's default and the usual choice for messaging
|
|
248
|
+
clients (the RabbitMQ Java client sets it too): an ack or a publisher confirm is a few bytes
|
|
249
|
+
and should go out at once, not wait on Nagle's algorithm for a delayed ACK. Previously Nagle
|
|
250
|
+
was left on.
|
|
251
|
+
|
|
5
252
|
## [0.8.1] - 2026-11-15
|
|
6
253
|
|
|
7
254
|
### Fixed
|
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@ of [Bunny](https://github.com/ruby-amqp/bunny) and [Async](https://github.com/so
|
|
|
7
7
|
|
|
8
8
|
```ruby
|
|
9
9
|
# Gemfile
|
|
10
|
-
gem "async-rabbitmq", "~> 0.
|
|
10
|
+
gem "async-rabbitmq", "~> 0.9"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
or
|
|
@@ -97,7 +97,7 @@ AsyncRabbitMQ::Session.new(
|
|
|
97
97
|
recover_topology: true, topology_recovery_filter: nil,
|
|
98
98
|
instrumenter: nil, # ->(event_name, payload) { ... }
|
|
99
99
|
notifier: nil, # or one Notifier shared between sessions
|
|
100
|
-
logger:
|
|
100
|
+
logger: Console # or Rails.logger, a Logger, or nil to discard
|
|
101
101
|
)
|
|
102
102
|
```
|
|
103
103
|
|
|
@@ -135,20 +135,55 @@ this does not cover, pass `tls_context:` and it is used as given.
|
|
|
135
135
|
|
|
136
136
|
### Logging
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
By default the client logs warnings and errors through
|
|
139
|
+
[Console](https://github.com/socketry/console), like the rest of the async stack.
|
|
140
|
+
How much it says is set in one place, whichever logger a session was given:
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
AsyncRabbitMQ.log_level = :warn # the default: warnings and errors
|
|
144
|
+
AsyncRabbitMQ.log_level = :debug # everything, when troubleshooting a connection
|
|
145
|
+
AsyncRabbitMQ.log_level = :off # nothing, from any session
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
ASYNC_RABBITMQ_LOG_LEVEL=debug bundle exec ruby worker.rb
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The level is checked before a message reaches any logger, so an application that
|
|
153
|
+
runs Console or Rails' logger at info does not get this client's info and debug
|
|
154
|
+
lines unless it asks for them. It is process-wide and can be changed at any time.
|
|
155
|
+
|
|
156
|
+
Every message names the object that logged it (the `Session`, a `Channel`, the
|
|
157
|
+
`FrameIO` connection layer, a `Cluster`), so Console's own controls can narrow it
|
|
158
|
+
further, per component. They act within `AsyncRabbitMQ.log_level`, never past it:
|
|
159
|
+
|
|
160
|
+
```ruby
|
|
161
|
+
AsyncRabbitMQ.log_level = :debug
|
|
162
|
+
Console.logger.filter(AsyncRabbitMQ::Channel, Console::Logger::DEBUG) # debug from channels
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Console's logger is per fiber, so a `Console.logger = ...` set before `connect`
|
|
166
|
+
also reaches every background task the session starts (the reader, heartbeat,
|
|
167
|
+
recovery loop and channel dispatchers).
|
|
168
|
+
|
|
169
|
+
To send this client's messages somewhere else, pass `logger:`. It takes anything
|
|
170
|
+
that responds to `debug`, `info`, `warn` and `error`, so use whatever your
|
|
171
|
+
application already has. Unlike reassigning `Console.logger`, this applies to one
|
|
172
|
+
session only, not to every Console user in the process. `nil` discards
|
|
173
|
+
everything.
|
|
141
174
|
|
|
142
175
|
```ruby
|
|
143
176
|
AsyncRabbitMQ::Session.new(logger: Rails.logger)
|
|
144
177
|
AsyncRabbitMQ::Session.new(logger: Logger.new($stdout, level: Logger::INFO))
|
|
145
|
-
AsyncRabbitMQ::Session.new(logger: AsyncRabbitMQ::Log.silent) # say nothing
|
|
146
178
|
AsyncRabbitMQ::Session.new(logger: AsyncRabbitMQ::Log.new($stdout, level: :debug))
|
|
179
|
+
AsyncRabbitMQ::Session.new(logger: nil) # say nothing
|
|
147
180
|
```
|
|
148
181
|
|
|
149
|
-
|
|
150
|
-
each, to `$stderr
|
|
151
|
-
|
|
182
|
+
`AsyncRabbitMQ::Log` is a minimal logger of that kind (warnings and errors, one
|
|
183
|
+
line each, to `$stderr`), for when you want a plain destination without the
|
|
184
|
+
`logger` gem, which stopped being a default gem in Ruby 4.0. Structured events
|
|
185
|
+
(see below) are the better hook for metrics and tracing; the log is for the
|
|
186
|
+
things a human should read.
|
|
152
187
|
|
|
153
188
|
## Channels
|
|
154
189
|
|