Record¶
minikafka.Record
dataclass
¶
Record(id: int, topic: str, created_at: datetime, handled_at: datetime | None, status: str, payload_hash: str, dedup_hash: str | None, data: ModelT, _source: Any = None)
Bases: Generic[ModelT]
A stored message returned by Topic.iter_new / Topic.iter_handled.
Records are frozen snapshots of the decoded Pydantic payload plus the
storage metadata kept in SQLite. Call record.ack() or
Topic.set_handled to transition the stored row from new to
handled.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Auto-incrementing primary key, unique within the database. |
topic |
str
|
Name of the topic the record belongs to. |
created_at |
datetime
|
UTC timestamp of when the record was inserted. |
handled_at |
datetime | None
|
UTC timestamp of when the record was acknowledged, or
|
status |
str
|
Either |
payload_hash |
str
|
SHA-256 over the canonical JSON of the full payload. |
dedup_hash |
str | None
|
SHA-256 over the dedup-field subset, or |
data |
ModelT
|
The decoded Pydantic model instance. |
Examples:
for record in topic.iter_new(records=True):
print(record.id, record.created_at, record.data)
record.ack()
ack ¶
Mark this record as handled.
Shorthand for topic.set_handled(record=self). The operation
is idempotent: calling ack() on an already-handled record
simply refreshes handled_at.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
The record was not produced by a topic iterator (missing source reference). |
Source code in src/minikafka/core.py
FanOutFailure¶
minikafka.FanOutFailure
dataclass
¶
A single sibling failure recorded during a best_effort fan-out run.
Instances are collected on the failures list of FanOutError when
FullPipeline.run(strategy="best_effort") is used. The parent record
that triggered the failure is left in the new state so a corrected
run can retry it.
Attributes:
| Name | Type | Description |
|---|---|---|
record_id |
int
|
Primary key of the parent record in its source topic. |
source |
str
|
Name of the topic that produced the record. |
target |
str | None
|
Name of the target topic the sibling pipeline was writing to,
or |
exception |
BaseException
|
The original exception raised by the sibling pipeline. |