consume_partitioned t ~sw ~clock ?retry ?on_retry ?on_warning ?queue_capacity ~handler is like consume but routes each message to a dedicated per-partition fiber. A partition's retry sleep blocks only that partition; other partitions continue unaffected. During retry sleep the partition is paused at the librdkafka level so no messages accumulate in its stream buffer.
Processing within a single partition is strictly sequential — ack commits by offset, so out-of-order acknowledgement within a partition would silently advance past unprocessed messages. Do not process two messages from the same partition concurrently against one t.
queue_capacity bounds each partition's message queue (default default_queue_capacity). Routing is a single loop that dispatches each message with a plain, synchronous, blocking add into its partition's queue — deliberately, not from a per-message fiber — so a partition whose queue is at capacity *does* stall routing to every other partition until it drains. This is a bounded stall (by queue_capacity, and by pause_partition already halting new deliveries to a partition during its own retry sleep, the most common cause of backlog), accepted in exchange for a hard memory bound — forking a fiber per message to avoid it was tried and reverted, since it replaces a bounded stall with unbounded fiber/memory growth.
on_retry ~partition ~attempt ~delay_s is called just before each retry sleep — use it to increment metrics counters. on_warning receives human-readable text for ack-misuse and retry/exhaustion events; defaults to stderr.
The function blocks until the consumer is stopped (handler returns Stop or retries are exhausted), then returns. All partition fibers are joined before returning, so the consumer handle is safe to close immediately after.
~sw is accepted for signature consistency with every other entry point in this library, but — unlike those — nothing is explicitly forked under it: internally, this function runs its own Eio.Switch.run so every partition fiber is provably joined before returning even if ~sw is cancelled mid-call, which a fiber forked directly under ~sw could not guarantee. This does not weaken cancellation: consume_partitioned runs synchronously within the calling fiber, so cancelling ~sw (or any ancestor switch) still stops this call exactly as it would any other blocking call made from a fiber registered under it. Calling close directly on t from another fiber also stops it, polled at a 100ms granularity — prefer cancelling ~sw for a tighter bound.