Configuration¶
All configuration is composed from frozen, immutable dataclasses.
RabbitConfig (top-level)¶
RabbitConfig
dataclass
¶
Top-level config — composes focused config objects.
Frozen + slots (per project convention). Brokers that need to apply
per-route overrides (e.g. prefetch) hold a private dataclasses.replace
copy rather than mutating the caller's object.
Only connection/broker defaults. Throughput/batching configs are accepted by their respective components directly.
Source code in src/rabbitkit/core/config.py
ConnectionConfig¶
ConnectionConfig
dataclass
¶
Core connection parameters.
Source code in src/rabbitkit/core/config.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
Attributes¶
url: str
property
¶
Build AMQP URL from config fields.
Username, password and vhost are URL-encoded so credentials containing
reserved characters (@:/# etc.) cannot corrupt the host/port parse
(mirrors the encoding done in async_/connection.py).
SECURITY (L2): this embeds the plaintext password (user:pass@host)
— never log or repr it. Use :attr:safe_url for logging/display.
safe_url: str
property
¶
Like :attr:url but with the password masked (L2) — safe to log.
Methods:¶
resolve_credentials() -> tuple[str, str]
¶
Return (username, password) — from credentials_provider if
set (M13: called at each (re)connect so rotated secrets are picked up
without a redeploy), else the static username/password fields.
Source code in src/rabbitkit/core/config.py
cluster_endpoints() -> list[tuple[str, int]]
¶
Primary host:port plus any failover nodes, in connect-attempt order.
Source code in src/rabbitkit/core/config.py
from_url(url: str) -> ConnectionConfig
classmethod
¶
Parse an AMQP URL into a ConnectionConfig.
Supports: amqp://user:pass@host:port/vhost?heartbeat=30&connection_timeout=10
Source code in src/rabbitkit/core/config.py
ConsumerConfig¶
ConsumerConfig
dataclass
¶
Consumer behavior tuning.
Source code in src/rabbitkit/core/config.py
PublisherConfig¶
PublisherConfig
dataclass
¶
Publisher behavior tuning.
Source code in src/rabbitkit/core/config.py
PoolConfig¶
PoolConfig
dataclass
¶
Connection and channel pool sizing.
channel_pool_size (publisher channel pool) and channel_acquire_timeout
are active. publisher_connections / consumer_connections are
reserved: the transport currently uses one connection per role, because
multiple connections sharing a single event loop showed no throughput benefit
in benchmarks (the loop is the bound). Scale throughput by running more
processes/pods, not more connections per process.
Source code in src/rabbitkit/core/config.py
RetryConfig¶
RetryConfig
dataclass
¶
Retry with delay queues configuration.
Accepted by RetryMiddleware. Can be set as broker default (RabbitConfig.retry) or per-route override (route.retry_override).
delays must have at least max_retries entries. Extra retries
beyond the length of delays would silently reuse the last delay,
which is almost always a misconfiguration.
Source code in src/rabbitkit/core/config.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
CompressionConfig¶
CompressionConfig
dataclass
¶
Compression configuration.
Accepted by CompressionMiddleware.
Source code in src/rabbitkit/core/config.py
SocketConfig¶
SocketConfig
dataclass
¶
Low-level TCP tuning.
Applied best-effort — not all options are universally guaranteed depending on OS and backend internals.
Sync-only. SyncBroker applies these via pika's tcp_options;
AsyncBroker emits a RuntimeWarning and ignores a non-default
value — aio-pika/aiormq exposes no socket-tuning hooks, and per-socket
tuning would be silently lost on every automatic reconnect. Tune the
async side via ConnectionConfig (heartbeat, timeouts) or at the
OS level.
Source code in src/rabbitkit/core/config.py
SSLConfig¶
SSLConfig
dataclass
¶
TLS/SSL configuration.
Source code in src/rabbitkit/core/config.py
SecurityConfig¶
SecurityConfig
dataclass
¶
SASL + authentication configuration.
Only mechanism="PLAIN" is implemented (username/password). EXTERNAL
(x509 client-cert auth) is not wired into either transport, so accepting
it silently would be "config that lies" — it is rejected at construction
(M2). mTLS is still supported for transport encryption via
SSLConfig(certfile=..., keyfile=...); it just isn't an auth mechanism.
Source code in src/rabbitkit/core/config.py
WorkerConfig¶
WorkerConfig
dataclass
¶
Consumer concurrency configuration.
Accepted by broker.start(), NOT part of RabbitConfig. Added in 0.2.0.
stop_timeout (H12): a FALLBACK drain deadline for the worker pool's
stop() — consulted only when no explicit timeout is passed. On the
standard shutdown path (broker.stop()) the pool drain budget is
ConsumerConfig.graceful_timeout, NOT this field — tune THAT (and
keep terminationGracePeriodSeconds a few seconds above it) for
Kubernetes; setting only stop_timeout there has no effect
(architect review M2 — the old text here said the opposite).
stop_timeout matters when you drive a worker pool directly. A
handler still running past this deadline is abandoned, not killed:
the sync pool's daemon thread keeps running in the background (it is
never forcibly stopped — Python cannot interrupt an arbitrary thread),
and the async pool cancels the task (which does not guarantee the
handler reaches its own ack/nack — CancelledError is a
BaseException and is not caught by the pipeline's exception
handling). Either way the abandoned delivery is logged by delivery
tag/message id, and — for the async pool — nacked for redelivery
immediately rather than relying on the implicit requeue that happens
when the connection eventually closes. Because the original handler may
still complete its side effects after abandonment, handlers must be
idempotent under at-least-once delivery regardless of stop_timeout.
Source code in src/rabbitkit/core/config.py
BackpressureConfig¶
BackpressureConfig
dataclass
¶
Backpressure configuration. Active.
Source code in src/rabbitkit/core/config.py
BatchPublishConfig¶
BatchPublishConfig
dataclass
¶
Batch publish configuration. Active.
Source code in src/rabbitkit/core/config.py
BatchAckConfig¶
BatchAckConfig
dataclass
¶
DeduplicationConfig¶
DeduplicationConfig
dataclass
¶
Deduplication configuration. Active.
mark_policy accepts a :class:~rabbitkit.core.types.DeduplicationMarkPolicy
member or its string value:
"on_success"(default) — crash-safe; concurrent duplicates may both run."on_start"— blocks concurrent duplicates but a crash mid-handler LOSES the message. Advanced/dangerous."claim"— in-flight claim (processing_timeout) before the handler, "completed" (ttl) after success. Blocks concurrent duplicates and survives crashes;processing_timeoutmust comfortably exceed the worst-case handler duration or a duplicate can start while the original is still running.
Source code in src/rabbitkit/core/config.py
HealthCheckConfig¶
HealthCheckConfig
dataclass
¶
MetricsConfig¶
MetricsConfig
dataclass
¶
Metrics naming configuration.
namespace sets the metric name prefix (default "rabbitkit").
Individual name fields override the derived default when non-empty.
Source code in src/rabbitkit/core/config.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | |
Attributes¶
dedup_fallback_total: str
property
¶
M9: incremented every time DeduplicationMiddleware falls back to
processing a message despite a Redis error (idempotency is not
enforced for that message) — see
DeduplicationConfig.fallback_on_redis_error.
rate_limit_dropped_total: str
property
¶
L5: incremented every time RateLimitMiddleware settles a message
without calling the handler — nack/drop policy, or the "wait" policy's
deadline elapsing with no token acquired. Labeled by reason
(nack/drop/wait_deadline_exceeded).
messages_redelivered_total: str
property
¶
Incremented (labeled by queue) for every consumed message the
broker flagged redelivered=True — the broker-redelivery-rate
signal. A sustained rise means handlers are dying/timing out before
acking (crash loops, heartbeat kills, connection churn), which the
success/error consume counters alone can't distinguish from ordinary
traffic.
reconnects_total: str
property
¶
Incremented on every transport re-connection after the first successful connect — the connection-churn signal. Reconnects were previously logged but never counted, so a flapping broker/network was invisible to metrics-based alerting.
channels_opened_total: str
property
¶
Incremented every time either transport actually creates a new
low-level channel — the publisher/topology channel, a per-queue
consumer channel, an async channel-pool slot, or a dedicated
fast/mandatory/reply-to channel. A steady climb with no matching
traffic growth signals a channel leak (a "cache" of channels that
never shrinks) — previously invisible, since only the connection
churn (reconnects_total) was counted.
channel_rebuilds_total: str
property
¶
Incremented when a channel is created to REPLACE one that died —
a reconnect-driven per-queue consumer channel recreate (sync), a
406-drift publisher channel reopen (sync), or a mandatory/fast
channel recycle after a timeout or closed-channel discovery (async).
Unlike channels_opened_total (every creation, including ordinary
pool growth and first-ever opens), this isolates the subset that
indicates something upstream actually failed.
queue_messages_ready: str
property
¶
Messages ready for delivery (backlog depth).
queue_messages_unacked: str
property
¶
Messages delivered but not yet acked (in-flight at consumers).
queue_messages_total: str
property
¶
Total messages in the queue (ready + unacked).
queue_consumers: str
property
¶
Number of consumers attached to the queue (0 = nothing draining).
RetryDisabled / RETRY_DISABLED¶
RetryDisabled
¶
Typed singleton — explicitly disables retry on a route.
Distinct from RetryConfig(max_retries=0) which means 'retry-owned terminal semantics with zero retry attempts (immediate DLQ on any classified error).'