Source code for aiokafka.structs

from dataclasses import dataclass
from typing import Generic, NamedTuple, Optional, Sequence, Tuple, TypeVar

from kafka.structs import (
    BrokerMetadata,
    OffsetAndMetadata,
    PartitionMetadata,
    TopicPartition,
)


__all__ = [
    "OffsetAndMetadata",
    "TopicPartition",
    "RecordMetadata",
    "ConsumerRecord",
    "BrokerMetadata",
    "PartitionMetadata",
]


[docs]class RecordMetadata(NamedTuple): """Returned when a :class:`~.AIOKafkaProducer` sends a message""" topic: str "The topic name" partition: int "The partition number" topic_partition: TopicPartition "" offset: int """The unique offset of the message in this partition. See :ref:`Offsets and Consumer Position <offset_and_position>` for more details on offsets. """ timestamp: Optional[int] "Timestamp in millis, None for older Brokers" timestamp_type: int """The timestamp type of this record. If the broker respected the timestamp passed to :meth:`.AIOKafkaProducer.send`, ``0`` will be returned (``CreateTime``). If the broker set it's own timestamp, ``1`` will be returned (``LogAppendTime``). """ log_start_offset: Optional[int] ""
KT = TypeVar("KT") VT = TypeVar("VT")
[docs]@dataclass class ConsumerRecord(Generic[KT, VT]): topic: str "The topic this record is received from" partition: int "The partition from which this record is received" offset: int "The position of this record in the corresponding Kafka partition." timestamp: int "The timestamp of this record" timestamp_type: int "The timestamp type of this record" key: Optional[KT] "The key (or `None` if no key is specified)" value: Optional[VT] "The value" checksum: int "Deprecated" serialized_key_size: int "The size of the serialized, uncompressed key in bytes." serialized_value_size: int "The size of the serialized, uncompressed value in bytes." headers: Sequence[Tuple[str, bytes]] "The headers"
[docs]class OffsetAndTimestamp(NamedTuple): offset: int timestamp: Optional[int] # Only None if used with old broker version