Resource

transaction

A transaction on a producer.

Requires transactional.id in the producer config, which implies enable.idempotence. The lifecycle is strict: begin, then produce, then commit or abort.

On any failure check error.txn-requires-abort: when set, the only legal next call is abort. When error.fatal is set the producer itself is finished and must be reopened.

resource transaction;

F send-offsets

send-offsets: async func(offsets: list​<partition-offset>, group-id: string) -> result​<_, error>;

Add consumer offsets to this transaction so consuming and producing commit atomically — the read-process-write pattern.

group-id is the consuming group; offsets are the positions to commit, normally one past the last record processed.

F commit

commit: async func() -> result​<_, error>;

Flush outstanding records and commit.

F abort

abort: async func() -> result​<_, error>;

Discard the transaction. Records already produced are marked aborted and are never delivered to read_committed consumers.

F begin

begin: async func(producer: borrow​<producer>) -> result​<transaction, error>;

Register the producer with its transaction coordinator, fencing any previous instance using the same transactional.id, and open a transaction.

Fencing is the point: it is what makes a restarted producer safe.