# Client guarantees

> What the Kafka client guarantees, capability by capability, and the brokers it supports.

Source: https://docs.pyrula.io/kafka/guarantees/

`yes` means the guarantee holds and `n/a` means the capability has no meaning for that
surface. `partial` on `compat.confluent` delivery means callbacks fire on `poll()` or
`flush()`, as confluent's do, rather than without polling.

The `compat.confluent` row is the [migration shim](https://docs.pyrula.io/kafka/confluent-compat.md): the native
rows' guarantees, observed through confluent-kafka's API.

| Surface | delivery | ordering | exit | offset commit | transactions | backpressure | rebalance |
|---|---|---|---|---|---|---|---|
| `producer` | yes | yes | yes | n/a | yes | yes | n/a |
| `consumer` | yes | n/a | yes | yes | yes | yes | yes |
| `compat.confluent` | partial | yes | yes | yes | yes | yes | yes |

## Column definitions

- **delivery:** A receipt resolves only after the broker acks the record per `acks` (default `all`), without the caller polling; a refused record fails its receipt with a typed error. See [Producer](https://docs.pyrula.io/kafka/producer.md).
- **ordering:** Records produced to one partition by one producer land in produce order, with `enable_idempotence=True`.
- **exit:** Closing settles what is in flight: a producer drains its queue, a consumer commits offsets staged with `store_offsets()` wherever a partition leaves. See [Producer](https://docs.pyrula.io/kafka/producer.md) and [Consumer](https://docs.pyrula.io/kafka/consumer.md).
- **offset commit:** Nothing is committed that was not polled; auto-commit is off by default (the `compat.confluent` shim defaults it on, as confluent-kafka does). See [Consumer](https://docs.pyrula.io/kafka/consumer.md).
- **transactions:** Produce, offset commit and transaction end land as one unit, and a `read_committed` consumer (the default) never sees an aborted record. See [Transactions](https://docs.pyrula.io/kafka/transactions.md).
- **backpressure:** A full queue refuses new work with `QueueFull` and never drops accepted work; `pause`/`resume` stop and restart fetch without losing position.
- **rebalance:** Callbacks fire in order with the consumer released, and offsets staged for revoked partitions are committed before they leave. The callback rules are in [Consumer](https://docs.pyrula.io/kafka/consumer.md).

## Install and tested versions

Supported brokers: Kafka 3.9+ (tested on 3.9 and 4.4), Confluent Platform 7.9+.

## Notes

- **`producer`:** `KafkaProducer` and `AsyncKafkaProducer` share one Rust actor; the async class drives it from the event loop's executor and inherits every cell here
- **`consumer`:** the async consumer (`AsyncKafkaConsumer`) delegates every call to a `KafkaConsumer` on a worker thread and returns what the sync call returns
- **`compat.confluent`:** A translation over the native rows, matching confluent-kafka 2.15.1's API. Cells hold within the translated config.
  - `enable.auto.commit` defaults to `True`, confluent-kafka's default (native: `False`); under it, `poll()` hands out what the tick, `close()` and a revoke commit. See [Migrating from confluent-kafka](https://docs.pyrula.io/kafka/confluent-compat.md).
  - A full queue raises `BufferError`, and confluent's `Producer` has no `close()`, so the `exit` cell is `flush()`.

## Differences from confluent-kafka

Each of these is covered by the matrix cell named in the last column.

| You are used to | Here | Cell |
|---|---|---|
| Records still queued when the producer is destroyed are dropped unless you `flush()` first | Leaving the context manager drains, under the retry budget `flush()` uses; what cannot be delivered fails its receipt. `purge()` drops instead | `producer`: exit |
| `close()` commits only when `enable.auto.commit` is on | Offsets staged with `store_offsets` are also committed at `close()` and on revoke when auto-commit is off | `consumer`: exit |
| Delivery callbacks fire only when you call `poll(0)` or `flush()` | Receipts resolve on the broker's ack without polling; the shim keeps confluent's poll-driven callbacks | `producer`: delivery |
