Kafka
Generated from the type stubs and docstrings. Do not edit by hand.
Acl(principal: str, host: str, operation: AclOperation, permission_type: AclPermissionType)Fields:
principal: strhost: stroperation: AclOperationpermission_type: AclPermissionType
AclCreation
Section titled “AclCreation”AclCreation(resource_type: AclResourceType, resource_name: str, principal: str, host: str, operation: AclOperation, permission_type: AclPermissionType, pattern_type: AclPatternType = ...)Fields:
resource_type: AclResourceTyperesource_name: strprincipal: strhost: stroperation: AclOperationpermission_type: AclPermissionTypepattern_type: AclPatternType
AclFilter
Section titled “AclFilter”AclFilter(resource_type: AclResourceType = ..., resource_name: Optional[str] = None, principal: Optional[str] = None, host: Optional[str] = None, operation: AclOperation = ..., permission_type: AclPermissionType = ..., pattern_type: AclPatternType = ..., confirm_match_all: bool = False)Fields:
resource_type: AclResourceTyperesource_name: Optional[str]principal: Optional[str]host: Optional[str]operation: AclOperationpermission_type: AclPermissionTypepattern_type: AclPatternTypeconfirm_match_all: bool
match_all
Section titled “match_all”match_all(cls) -> SelfAclOperation
Section titled “AclOperation”Fields:
UNKNOWN: intANY: intALL: intREAD: intWRITE: intCREATE: intDELETE: intALTER: intDESCRIBE: intCLUSTER_ACTION: intDESCRIBE_CONFIGS: intALTER_CONFIGS: intIDEMPOTENT_WRITE: int
AclPatternType
Section titled “AclPatternType”Fields:
UNKNOWN: intANY: intMATCH: intLITERAL: intPREFIXED: int
AclPermissionType
Section titled “AclPermissionType”Fields:
UNKNOWN: intANY: intDENY: intALLOW: int
AclResource
Section titled “AclResource”AclResource(resource_type: AclResourceType, resource_name: str, acls: IList[Acl] = ..., pattern_type: AclPatternType = ...)Fields:
resource_type: AclResourceTyperesource_name: stracls: IList[Acl]pattern_type: AclPatternType
AclResourceType
Section titled “AclResourceType”Fields:
UNKNOWN: intANY: intTOPIC: intGROUP: intCLUSTER: intTRANSACTIONAL_ID: intDELEGATION_TOKEN: int
AclResult
Section titled “AclResult”AclResult(error: str = '')Fields:
error: str
AdminError
Section titled “AdminError”AlterConfigOpType
Section titled “AlterConfigOpType”Fields:
SET: intDELETE: intAPPEND: intSUBTRACT: int
ArrowBatch
Section titled “ArrowBatch”Fields:
num_rows: int
ArrowPollResult
Section titled “ArrowPollResult”Fields:
batch: ArrowBatchoffsets: dict[tuple[str, int], int]
AsyncKafkaConsumer
Section titled “AsyncKafkaConsumer”Delegates every call to a KafkaConsumer on a worker thread; each method returns
exactly what its sync counterpart on KafkaConsumer returns. The worker serves
concurrent coroutines one at a time, so they never meet the one-poller refusal.
AsyncKafkaConsumer(config: KafkaConsumerConfig)close(self) -> Nonepoll_batch
Section titled “poll_batch”poll_batch(self, max_records: int = 500, timeout_ms: int = 500) -> Either[KafkaBatch, KafkaError]poll_bytes_batch
Section titled “poll_bytes_batch”poll_bytes_batch(self, max_records: int = 500, timeout_ms: int = 500) -> Either[BytesBatch, KafkaError]consume
Section titled “consume”consume(self, max_records: int = 500, timeout_ms: int = 500) -> AsyncIterator[KafkaRecord]store_offsets
Section titled “store_offsets”store_offsets(self, batch_or_offsets: KafkaBatch | BytesBatch | IMap[TopicPartition, int]) -> Either[None, KafkaError]commit
Section titled “commit”commit(self, batch: Optional[KafkaBatch | BytesBatch | IMap[TopicPartition, int]] = None) -> Either[CommitReport, KafkaError]commit_offsets
Section titled “commit_offsets”commit_offsets(self, offsets: IMap[TopicPartition, int]) -> Either[CommitReport, KafkaError]subscribe
Section titled “subscribe”subscribe(self, topics: IList[str] | list[str] | str | re.Pattern[str], on_assign: Optional[Callable[[KafkaConsumer, IList[TopicPartition]], None]] = None, on_revoke: Optional[Callable[[KafkaConsumer, IList[TopicPartition]], None]] = None, on_lost: Optional[Callable[[KafkaConsumer, IList[TopicPartition]], None]] = None) -> Either[None, ConsumerError]unsubscribe
Section titled “unsubscribe”unsubscribe(self) -> Either[None, ConsumerError]assign
Section titled “assign”assign(self, partitions: IList[TopicPartition] | list[TopicPartition], start_offsets: Optional[IMap[TopicPartition, int] | dict[TopicPartition, int]] = None) -> Either[None, ConsumerError]unassign
Section titled “unassign”unassign(self) -> Either[None, ConsumerError]assignment
Section titled “assignment”assignment(self) -> IList[TopicPartition]seek(self, topic_partition: TopicPartition, offset: int) -> Either[None, ConsumerError]seek_to_beginning
Section titled “seek_to_beginning”seek_to_beginning(self, topic_partition: TopicPartition) -> Either[None, ConsumerError]seek_to_end
Section titled “seek_to_end”seek_to_end(self, topic_partition: TopicPartition) -> Either[None, ConsumerError]rewind
Section titled “rewind”rewind(self, batch: KafkaBatch) -> Either[None, ConsumerError]committed
Section titled “committed”committed(self, topic_partition: TopicPartition) -> Option[int]committed(self, topic_partition: IList[TopicPartition] | list[TopicPartition]) -> IMap[TopicPartition, Option[int]]position
Section titled “position”position(self, topic_partition: TopicPartition) -> intget_watermark_offsets
Section titled “get_watermark_offsets”get_watermark_offsets(self, topic_partition: TopicPartition, timeout_ms: Optional[int] = None) -> Either[tuple[int, int], ConsumerError]offsets_for_times
Section titled “offsets_for_times”offsets_for_times(self, tp_timestamps: IMap[TopicPartition, int], timeout_ms: Optional[int] = None) -> Either[IMap[TopicPartition, int], ConsumerError]pause(self, partitions: Optional[IList[TopicPartition] | list[TopicPartition]] = None) -> Either[None, KafkaError]resume
Section titled “resume”resume(self, partitions: Optional[IList[TopicPartition] | list[TopicPartition]] = None) -> Either[None, KafkaError]list_topics
Section titled “list_topics”list_topics(self) -> Either[IList[str], ConsumerError]subscription
Section titled “subscription”subscription(self) -> IList[str]lag(self) -> Either[IMap[TopicPartition, int], KafkaError]memberid
Section titled “memberid”memberid(self) -> strconsumer_group_metadata
Section titled “consumer_group_metadata”consumer_group_metadata(self) -> Option[ConsumerGroupMetadata]metrics
Section titled “metrics”metrics(self) -> dict[str, int]AsyncKafkaProducer
Section titled “AsyncKafkaProducer”Runs every call of a KafkaProducer on the event loop’s executor; each method
returns exactly what its sync counterpart on KafkaProducer returns. Usable from
several event loops and threads at once: calls awaited in sequence keep their order,
concurrent coroutines do not, as threads calling KafkaProducer do not.
AsyncKafkaProducer(config: KafkaConfig)close(self) -> Noneproduce
Section titled “produce”produce(self, topic: str, value: Optional[bytes], key: Optional[bytes] = None, *, partition: int = -1, headers: Optional[dict[str, bytes] | IMap[str, bytes] | Sequence[tuple[str, bytes]]] = None, timestamp_ms: Optional[int] = None) -> ProduceReceiptproduce_many_bytes
Section titled “produce_many_bytes”produce_many_bytes(self, topic: str, values: BytesList | IList[bytes] | list[bytes], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> ProduceReceiptproduce_many_json
Section titled “produce_many_json”produce_many_json(self, topic: str, values: IList[dict] | list[dict], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> ProduceReceiptproduce_many_avro
Section titled “produce_many_avro”produce_many_avro(self, topic: str, values: IList[dict] | list[dict], serde: AvroSerde, keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> ProduceReceiptproduce_many_bytes_sync
Section titled “produce_many_bytes_sync”produce_many_bytes_sync(self, topic: str, values: BytesList | IList[bytes] | list[bytes], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> Either[ProduceReport, KafkaError]produce_many_json_sync
Section titled “produce_many_json_sync”produce_many_json_sync(self, topic: str, values: IList[dict] | list[dict], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> Either[ProduceReport, KafkaError]flush(self, timeout_ms: Optional[int] = None) -> Either[FlushReport, KafkaError]purge(self, in_queue: bool = True, in_flight: bool = True, blocking: bool = True) -> Either[int, KafkaError]produce_many_records_sync
Section titled “produce_many_records_sync”produce_many_records_sync(self, records: IList[KafkaRecord] | list[KafkaRecord]) -> Either[ProduceReport, KafkaError]init_transactions
Section titled “init_transactions”init_transactions(self, timeout_ms: Optional[int] = None) -> Either[None, KafkaError]begin_transaction
Section titled “begin_transaction”begin_transaction(self) -> Either[None, KafkaError]commit_transaction
Section titled “commit_transaction”commit_transaction(self, timeout_ms: Optional[int] = None) -> Either[None, KafkaError]abort_transaction
Section titled “abort_transaction”abort_transaction(self, timeout_ms: Optional[int] = None) -> Either[None, KafkaError]produce_many_records_txn
Section titled “produce_many_records_txn”produce_many_records_txn(self, records: IList[KafkaRecord] | list[KafkaRecord]) -> ProduceReceiptsend_offsets_to_transaction
Section titled “send_offsets_to_transaction”send_offsets_to_transaction(self, offsets: IMap[TopicPartition, int], consumer_group_metadata: ConsumerGroupMetadata | Option[ConsumerGroupMetadata], timeout_ms: Optional[int] = None) -> Either[None, KafkaError]metrics
Section titled “metrics”metrics(self) -> dict[str, int]BrokerMetadata
Section titled “BrokerMetadata”BrokerMetadata(node_id: int, host: str, port: int, rack: Optional[str] = None)Fields:
node_id: inthost: strport: intrack: Optional[str]
BytesBatch
Section titled “BytesBatch”BytesBatch(values: object, offsets: IMap[TopicPartition, int], count: int)Fields:
values: objectoffsets: IMap[TopicPartition, int]count: int
ClusterMetadata
Section titled “ClusterMetadata”ClusterMetadata(brokers: IList[BrokerMetadata] = ..., controller_id: int = -1, topics: IList[TopicMetadata] = ..., cluster_id: Optional[str] = None)Fields:
brokers: IList[BrokerMetadata]controller_id: inttopics: IList[TopicMetadata]cluster_id: Optional[str]
CommitError
Section titled “CommitError”CommitReport
Section titled “CommitReport”CommitReport(committed: IMap[TopicPartition, int])Fields:
committed: IMap[TopicPartition, int]
ConfigEntry
Section titled “ConfigEntry”ConfigEntry(name: str, value: Optional[str] = None, incremental_operation: Optional[AlterConfigOpType] = None, source: ConfigSource = ..., is_default: bool = False, is_sensitive: bool = False, read_only: bool = False)Fields:
name: strvalue: Optional[str]incremental_operation: Optional[AlterConfigOpType]source: ConfigSourceis_default: boolis_sensitive: boolread_only: bool
ConfigError
Section titled “ConfigError”ConfigResource
Section titled “ConfigResource”ConfigResource(resource_type: ResourceType, name: str, set_config: IMap[str, str] = ..., incremental_configs: IList[ConfigEntry] = ...)Fields:
resource_type: ResourceTypename: strset_config: IMap[str, str]incremental_configs: IList[ConfigEntry]
ConfigSource
Section titled “ConfigSource”Fields:
UNKNOWN: intDYNAMIC_TOPIC_CONFIG: intDYNAMIC_BROKER_CONFIG: intDYNAMIC_DEFAULT_BROKER_CONFIG: intSTATIC_BROKER_CONFIG: intDEFAULT_CONFIG: intDYNAMIC_BROKER_LOGGER_CONFIG: int
ConsumerError
Section titled “ConsumerError”ConsumerGroupDetail
Section titled “ConsumerGroupDetail”ConsumerGroupDetail(group_id: str, state: str, protocol_type: str, protocol: str, members: IList[ConsumerGroupMember])Fields:
group_id: strstate: strprotocol_type: strprotocol: strmembers: IList[ConsumerGroupMember]
ConsumerGroupInfo
Section titled “ConsumerGroupInfo”ConsumerGroupInfo(group_id: str, protocol_type: str)Fields:
group_id: strprotocol_type: str
ConsumerGroupMember
Section titled “ConsumerGroupMember”ConsumerGroupMember(member_id: str, client_id: str, host: str, assignment: IList[TopicPartition])Fields:
member_id: strclient_id: strhost: strassignment: IList[TopicPartition]
ConsumerGroupMetadata
Section titled “ConsumerGroupMetadata”ConsumerGroupMetadata(group_id: str, coordinator_addr: str)Fields:
group_id: strcoordinator_addr: str
DeletedRecords
Section titled “DeletedRecords”DeletedRecords(low_watermark: int)Fields:
low_watermark: int
Deliveries
Section titled “Deliveries”Native sequence, one slot per accepted record in produce order: a DeliveryReport
where the record landed (offset -1 when the broker did not state it: acks=0), None
where it did not - exact on every path, with or without idempotence, whatever acks
is, and in a transaction. Built by the Rust
core; the constructor exists for tests and the empty default, with -2**63 in
offsets marking a record that did not land.
Deliveries(topic: str, partitions: list[int], offsets: list[int])DeliveryReport
Section titled “DeliveryReport”Where one produced record landed: an element of ProduceReport.deliveries.
offset is -1 when the broker confirmed delivery without an offset
(acks=0, or a duplicate-sequence acknowledgement).
DeliveryReport(topic: str, partition: int, offset: int)Fields:
topic: strpartition: intoffset: int
DeliveryTimeout
Section titled “DeliveryTimeout”FlushReport
Section titled “FlushReport”FlushReport(flushed: int, elapsed_ms: int)Fields:
flushed: intelapsed_ms: int
KafkaAdminClient
Section titled “KafkaAdminClient”Kafka admin client. Safe to share between threads; calls from several threads
run at once, as confluent-kafka’s AdminClient allows.
KafkaAdminClient(config: KafkaConfig)create_topics
Section titled “create_topics”create_topics(self, specs: IList[TopicSpec] | list[TopicSpec], validate_only: bool = False, operation_timeout_ms: int = 30000, request_timeout_ms: Optional[int] = None) -> Either[IList[TopicResult], AdminError]delete_topics
Section titled “delete_topics”delete_topics(self, topics: IList[str] | list[str]) -> Either[IList[TopicResult], AdminError]list_consumer_groups
Section titled “list_consumer_groups”list_consumer_groups(self) -> Either[IList[ConsumerGroupInfo], AdminError]describe_consumer_groups
Section titled “describe_consumer_groups”describe_consumer_groups(self, group_ids: IList[str] | list[str]) -> Either[IList[ConsumerGroupDetail], AdminError]delete_consumer_groups
Section titled “delete_consumer_groups”delete_consumer_groups(self, group_ids: IList[str] | list[str]) -> Either[IList[TopicResult], AdminError]create_partitions
Section titled “create_partitions”create_partitions(self, new_partitions: IList[NewPartitions] | list[NewPartitions], validate_only: bool = False, operation_timeout_ms: int = 30000) -> Either[IList[TopicResult], AdminError]list_topics
Section titled “list_topics”list_topics(self) -> Either[IList[str], AdminError]describe_cluster
Section titled “describe_cluster”describe_cluster(self, include_authorized_operations: bool = False) -> Either[ClusterMetadata, AdminError]describe_topics
Section titled “describe_topics”describe_topics(self, topics: IList[str] | list[str] | IList[TopicMetadata] | list[TopicMetadata], include_authorized_operations: bool = False) -> Either[IList[TopicMetadata], AdminError]describe_configs
Section titled “describe_configs”describe_configs(self, resources: IList[ConfigResource] | list[ConfigResource] | IList[str] | list[str]) -> Either[IMap[str, IMap[str, str]], AdminError]describe_topic_config
Section titled “describe_topic_config”describe_topic_config(self, topics: IList[str] | list[str]) -> Either[IMap[str, IMap[str, str]], AdminError]incremental_alter_configs
Section titled “incremental_alter_configs”incremental_alter_configs(self, resources: IList[ConfigResource] | list[ConfigResource], validate_only: bool = False) -> Either[None, AdminError]list_offsets
Section titled “list_offsets”list_offsets(self, offset_specs: IMap[TopicPartition, OffsetSpec], isolation_level: str = 'read_committed') -> Either[IMap[TopicPartition, ListOffsetsResultInfo], AdminError]delete_records
Section titled “delete_records”delete_records(self, offsets: IMap[TopicPartition, int], operation_timeout_ms: int = 30000) -> Either[IMap[TopicPartition, DeletedRecords], AdminError]list_consumer_group_offsets
Section titled “list_consumer_group_offsets”list_consumer_group_offsets(self, group_id: str, topics: Optional[IList[TopicPartition] | list[TopicPartition]] = None) -> Either[IMap[TopicPartition, int], AdminError]alter_consumer_group_offsets
Section titled “alter_consumer_group_offsets”alter_consumer_group_offsets(self, group_id: str, offsets: IMap[TopicPartition, int]) -> Either[None, AdminError]create_acls
Section titled “create_acls”create_acls(self, acls: IList[AclCreation] | list[AclCreation]) -> Either[IList[AclResult], AdminError]describe_acls
Section titled “describe_acls”describe_acls(self, resource_type: int = 1, resource_name: Optional[str] = None, principal: Optional[str] = None, host: Optional[str] = None, operation: int = 1, permission_type: int = 1, pattern_type: int = 1) -> Either[IList[AclResource], AdminError]delete_acls
Section titled “delete_acls”delete_acls(self, filters: IList[AclFilter] | list[AclFilter]) -> Either[IList[AclResult], AdminError]KafkaBatch
Section titled “KafkaBatch”KafkaBatch(records: IList[KafkaRecord], offsets: IMap[TopicPartition, int], count: int)Fields:
records: IList[KafkaRecord]offsets: IMap[TopicPartition, int]count: int
KafkaConfig
Section titled “KafkaConfig”KafkaConfig(bootstrap_servers: str, client_id: str = 'pyrula', acks: str | int = 'all', compression: str = 'none', partitioner: str = 'murmur2', linger_ms: int = 5, batch_size_bytes: int = 131072, batch_num_messages: int = 10000, sticky_partitioning_linger_ms: Optional[int] = None, max_in_flight_requests_per_connection: Optional[int] = None, topic_metadata_refresh_interval_ms: int = 300000, connect_in_background: bool = False, max_request_bytes: int = 1048576, coalesce_produce_requests: bool = False, raw_connections_per_broker: int = 8, enable_idempotence: Optional[bool] = None, message_timeout_ms: Optional[int] = None, request_timeout_ms: int = 30000, retry_backoff_ms: int = 100, message_send_max_retries: int = 2147483647, queue_buffering_max_messages: int = 100000, queue_buffering_max_kbytes: int = 1048576, transactional_id: str = '', security_protocol: str = 'PLAINTEXT', sasl_mechanism: str = 'PLAIN', sasl_username: Optional[str] = None, sasl_password: Optional[str] = None, oauth_cb: Optional[Callable[[], tuple[str, float] | tuple[str, float, Optional[str]] | tuple[str, float, Optional[str], Optional[dict[str, str]]]]] = None, ssl_ca_location: Optional[str] = None, ssl_certificate_location: Optional[str] = None, ssl_key_location: Optional[str] = None, error_cb: Optional[Callable[[Exception], None]] = None, logger: Optional[logging.Logger] = None, statistics_interval_ms: int = 0, stats_cb: Optional[Callable[[dict[str, int]], None]] = None, extra: Any = ...)Fields:
bootstrap_servers: strclient_id: stracks: str | intcompression: strpartitioner: strlinger_ms: intbatch_size_bytes: intbatch_num_messages: intsticky_partitioning_linger_ms: Optional[int]max_in_flight_requests_per_connection: Optional[int]topic_metadata_refresh_interval_ms: intconnect_in_background: boolmax_request_bytes: intcoalesce_produce_requests: boolraw_connections_per_broker: intenable_idempotence: Optional[bool]message_timeout_ms: Optional[int]request_timeout_ms: intretry_backoff_ms: intmessage_send_max_retries: intqueue_buffering_max_messages: intqueue_buffering_max_kbytes: inttransactional_id: strsecurity_protocol: strsasl_mechanism: strsasl_username: Optional[str]sasl_password: Optional[str]oauth_cb: Optional[Callable[[], tuple[str, float] | tuple[str, float, Optional[str]] | tuple[str, float, Optional[str], Optional[dict[str, str]]]]]ssl_ca_location: Optional[str]ssl_certificate_location: Optional[str]ssl_key_location: Optional[str]error_cb: Optional[Callable[[Exception], None]]logger: Optional[logging.Logger]statistics_interval_ms: intstats_cb: Optional[Callable[[dict[str, int]], None]]extra: Any
KafkaConnectionError
Section titled “KafkaConnectionError”KafkaConsumer
Section titled “KafkaConsumer”Blocking Kafka consumer.
Other threads may call it while one thread polls, as confluent-kafka’s consumer
allows: commits, stored offsets, seeks, pauses, positions and the rest are served
at once. One thread polls at a time; a second concurrent poll_*() raises
ConsumerError (_conflicting_use). close() from another thread wakes a
blocked poll, which returns an empty batch, then leaves the group once. Rebalance
callbacks run on the thread whose call drove the rebalance and may call back into
the consumer; stats_cb, error_cb and a logger may too, except to poll or close
from inside this thread’s own poll, or to change the subscription from inside a
rebalance this thread is running (_conflicting_use). A background error_cb runs
on a client thread, where consumer calls are refused. metrics() answers
from any thread at any time. Dropping the consumer without close() frees it but
does not leave the group promptly: the group waits out the session, as with
confluent-kafka. Call close() to leave and commit staged offsets.
KafkaConsumer(config: KafkaConsumerConfig)poll_batch
Section titled “poll_batch”poll_batch(self, max_records: int = 10000, timeout_ms: int = 100) -> Either[KafkaBatch, KafkaError]poll_bytes_batch
Section titled “poll_bytes_batch”poll_bytes_batch(self, max_records: int = 10000, timeout_ms: int = 100) -> Either[BytesBatch, KafkaError]poll_bytes_packed
Section titled “poll_bytes_packed”poll_bytes_packed(self, max_records: int = 10000, timeout_ms: int = 100) -> Either[PackedBytesBatch, KafkaError]poll_bytes_batch_spans
Section titled “poll_bytes_batch_spans”poll_bytes_batch_spans(self, max_records: int = 10000, timeout_ms: int = 100) -> Either[tuple[BytesBatch, list[tuple[int, int, int]]], KafkaError]poll_arrow
Section titled “poll_arrow”poll_arrow(self, max_records: int = 10000, timeout_ms: int = 100, value_format: str = 'raw', schema: Optional[str] = None, include_metadata: bool = True) -> Either[ArrowPollResult, KafkaError]store_offsets
Section titled “store_offsets”store_offsets(self, batch_or_offsets: KafkaBatch | BytesBatch | IMap[TopicPartition, int]) -> Either[None, KafkaError]commit
Section titled “commit”commit(self, batch: Optional[KafkaBatch | BytesBatch | IMap[TopicPartition, int]] = None) -> Either[CommitReport, KafkaError]commit_offsets
Section titled “commit_offsets”commit_offsets(self, offsets: IMap[TopicPartition, int]) -> Either[CommitReport, KafkaError]subscribe
Section titled “subscribe”subscribe(self, topics: IList[str] | list[str] | str | re.Pattern[str], on_assign: Optional[Callable[[KafkaConsumer, IList[TopicPartition]], None]] = None, on_revoke: Optional[Callable[[KafkaConsumer, IList[TopicPartition]], None]] = None, on_lost: Optional[Callable[[KafkaConsumer, IList[TopicPartition]], None]] = None) -> Either[None, ConsumerError]unsubscribe
Section titled “unsubscribe”unsubscribe(self) -> Either[None, ConsumerError]assign
Section titled “assign”assign(self, partitions: IList[TopicPartition] | list[TopicPartition], start_offsets: Optional[IMap[TopicPartition, int] | dict[TopicPartition, int]] = None) -> Either[None, ConsumerError]unassign
Section titled “unassign”unassign(self) -> Either[None, ConsumerError]assignment
Section titled “assignment”assignment(self) -> IList[TopicPartition]incremental_assign
Section titled “incremental_assign”incremental_assign(self, partitions: IList[TopicPartition] | list[TopicPartition], start_offsets: Optional[IMap[TopicPartition, int] | dict[TopicPartition, int]] = None) -> Either[None, ConsumerError]incremental_unassign
Section titled “incremental_unassign”incremental_unassign(self, partitions: IList[TopicPartition] | list[TopicPartition]) -> Either[None, ConsumerError]seek(self, topic_partition: TopicPartition, offset: int) -> Either[None, ConsumerError]seek_to_beginning
Section titled “seek_to_beginning”seek_to_beginning(self, topic_partition: TopicPartition) -> Either[None, ConsumerError]seek_to_end
Section titled “seek_to_end”seek_to_end(self, topic_partition: TopicPartition) -> Either[None, ConsumerError]rewind
Section titled “rewind”rewind(self, batch: KafkaBatch) -> Either[None, ConsumerError]position
Section titled “position”position(self, topic_partition: TopicPartition) -> intcommitted
Section titled “committed”committed(self, topic_partition: TopicPartition) -> Option[int]committed(self, topic_partition: IList[TopicPartition] | list[TopicPartition]) -> IMap[TopicPartition, Option[int]]get_watermark_offsets
Section titled “get_watermark_offsets”get_watermark_offsets(self, topic_partition: TopicPartition, timeout_ms: Optional[int] = None) -> Either[tuple[int, int], ConsumerError]offsets_for_times
Section titled “offsets_for_times”offsets_for_times(self, tp_timestamps: IMap[TopicPartition, int], timeout_ms: Optional[int] = None) -> Either[IMap[TopicPartition, int], ConsumerError]pause(self, partitions: Optional[IList[TopicPartition] | list[TopicPartition]] = None) -> Either[None, KafkaError]resume
Section titled “resume”resume(self, partitions: Optional[IList[TopicPartition] | list[TopicPartition]] = None) -> Either[None, KafkaError]list_topics
Section titled “list_topics”list_topics(self) -> Either[IList[str], ConsumerError]subscription
Section titled “subscription”subscription(self) -> IList[str]lag(self) -> Either[IMap[TopicPartition, int], KafkaError]memberid
Section titled “memberid”memberid(self) -> strconsumer_group_metadata
Section titled “consumer_group_metadata”consumer_group_metadata(self) -> Option[ConsumerGroupMetadata]metrics
Section titled “metrics”metrics(self) -> dict[str, int]close(self) -> NoneKafkaConsumerConfig
Section titled “KafkaConsumerConfig”KafkaConsumerConfig(bootstrap_servers: str, topics: list[str], group_id: str = '', group_instance_id: str = '', enable_auto_commit: bool = False, auto_commit_interval_ms: int = 5000, auto_offset_reset: str = 'earliest', max_poll_interval_ms: int = 300000, session_timeout_ms: int = 10000, heartbeat_interval_ms: int = 3000, request_timeout_ms: int = 30000, partition_assignment_strategy: str = 'range', rebalance_timeout_ms: Optional[int] = None, topic_metadata_refresh_interval_ms: int = 300000, topic_metadata_refresh_fast_interval_ms: int = 250, isolation_level: str = 'read_committed', max_poll_records: int = 500, fetch_max_bytes: int = 52428800, fetch_min_bytes: int = 1, fetch_wait_max_ms: int = 500, max_partition_fetch_bytes: int = 1048576, fetch_mode: str = 'auto', prefetch_max_bytes: int = 67108864, security_protocol: str = 'PLAINTEXT', sasl_mechanism: str = 'PLAIN', sasl_username: Optional[str] = None, sasl_password: Optional[str] = None, oauth_cb: Optional[Callable[[], tuple[str, float] | tuple[str, float, Optional[str]] | tuple[str, float, Optional[str], Optional[dict[str, str]]]]] = None, ssl_ca_location: Optional[str] = None, ssl_certificate_location: Optional[str] = None, ssl_key_location: Optional[str] = None, error_cb: Optional[Callable[[Exception], None]] = None, logger: Optional[logging.Logger] = None, statistics_interval_ms: int = 0, stats_cb: Optional[Callable[[dict[str, int]], None]] = None, extra: Any = ..., client_id: str = 'pyrula', allow_auto_create_topics: bool = False)Fields:
bootstrap_servers: strtopics: list[str]group_id: strgroup_instance_id: strenable_auto_commit: boolauto_commit_interval_ms: intauto_offset_reset: strmax_poll_interval_ms: intsession_timeout_ms: intheartbeat_interval_ms: intrequest_timeout_ms: intpartition_assignment_strategy: strrebalance_timeout_ms: Optional[int]topic_metadata_refresh_interval_ms: inttopic_metadata_refresh_fast_interval_ms: intisolation_level: strmax_poll_records: intfetch_max_bytes: intfetch_min_bytes: intfetch_wait_max_ms: intmax_partition_fetch_bytes: intfetch_mode: strprefetch_max_bytes: intsecurity_protocol: strsasl_mechanism: strsasl_username: Optional[str]sasl_password: Optional[str]oauth_cb: Optional[Callable[[], tuple[str, float] | tuple[str, float, Optional[str]] | tuple[str, float, Optional[str], Optional[dict[str, str]]]]]ssl_ca_location: Optional[str]ssl_certificate_location: Optional[str]ssl_key_location: Optional[str]error_cb: Optional[Callable[[Exception], None]]logger: Optional[logging.Logger]statistics_interval_ms: intstats_cb: Optional[Callable[[dict[str, int]], None]]extra: Anyclient_id: strallow_auto_create_topics: bool
KafkaError
Section titled “KafkaError”KafkaErrorCode
Section titled “KafkaErrorCode”Named Kafka broker error codes (confluent-kafka compatible).
Fields:
UNKNOWN_SERVER_ERROR: intNO_ERROR: intOFFSET_OUT_OF_RANGE: intCORRUPT_MESSAGE: intUNKNOWN_TOPIC_OR_PARTITION: intINVALID_FETCH_SIZE: intLEADER_NOT_AVAILABLE: intNOT_LEADER_OR_FOLLOWER: intREQUEST_TIMED_OUT: intBROKER_NOT_AVAILABLE: intREPLICA_NOT_AVAILABLE: intMESSAGE_TOO_LARGE: intSTALE_CONTROLLER_EPOCH: intOFFSET_METADATA_TOO_LARGE: intNETWORK_EXCEPTION: intCOORDINATOR_LOAD_IN_PROGRESS: intCOORDINATOR_NOT_AVAILABLE: intNOT_COORDINATOR: intINVALID_TOPIC_EXCEPTION: intRECORD_LIST_TOO_LARGE: intNOT_ENOUGH_REPLICAS: intNOT_ENOUGH_REPLICAS_AFTER_APPEND: intINVALID_REQUIRED_ACKS: intILLEGAL_GENERATION: intINCONSISTENT_GROUP_PROTOCOL: intINVALID_GROUP_ID: intUNKNOWN_MEMBER_ID: intINVALID_SESSION_TIMEOUT: intREBALANCE_IN_PROGRESS: intINVALID_COMMIT_OFFSET_SIZE: intTOPIC_AUTHORIZATION_FAILED: intGROUP_AUTHORIZATION_FAILED: intCLUSTER_AUTHORIZATION_FAILED: intINVALID_TIMESTAMP: intUNSUPPORTED_SASL_MECHANISM: intILLEGAL_SASL_STATE: intUNSUPPORTED_VERSION: intTOPIC_ALREADY_EXISTS: intINVALID_PARTITIONS: intINVALID_REPLICATION_FACTOR: intINVALID_REPLICA_ASSIGNMENT: intINVALID_CONFIG: intNOT_CONTROLLER: intINVALID_REQUEST: intUNSUPPORTED_FOR_MESSAGE_FORMAT: intPOLICY_VIOLATION: intOUT_OF_ORDER_SEQUENCE_NUMBER: intDUPLICATE_SEQUENCE_NUMBER: intINVALID_PRODUCER_EPOCH: intINVALID_TXN_STATE: intINVALID_PRODUCER_ID_MAPPING: intINVALID_TRANSACTION_TIMEOUT: intCONCURRENT_TRANSACTIONS: intTRANSACTION_COORDINATOR_FENCED: intTRANSACTIONAL_ID_AUTHORIZATION_FAILED: intSECURITY_DISABLED: intOPERATION_NOT_ATTEMPTED: intKAFKA_STORAGE_ERROR: intLOG_DIR_NOT_FOUND: intSASL_AUTHENTICATION_FAILED: intUNKNOWN_PRODUCER_ID: intREASSIGNMENT_IN_PROGRESS: intDELEGATION_TOKEN_AUTH_DISABLED: intDELEGATION_TOKEN_NOT_FOUND: intDELEGATION_TOKEN_OWNER_MISMATCH: intDELEGATION_TOKEN_REQUEST_NOT_ALLOWED: intDELEGATION_TOKEN_AUTHORIZATION_FAILED: intDELEGATION_TOKEN_EXPIRED: intINVALID_PRINCIPAL_TYPE: intNON_EMPTY_GROUP: intGROUP_ID_NOT_FOUND: intFETCH_SESSION_ID_NOT_FOUND: intINVALID_FETCH_SESSION_EPOCH: intLISTENER_NOT_FOUND: intTOPIC_DELETION_DISABLED: intFENCED_LEADER_EPOCH: intUNKNOWN_LEADER_EPOCH: intUNSUPPORTED_COMPRESSION_TYPE: intSTALE_BROKER_EPOCH: intOFFSET_NOT_AVAILABLE: intMEMBER_ID_REQUIRED: intPREFERRED_LEADER_NOT_AVAILABLE: intGROUP_MAX_SIZE_REACHED: intFENCED_INSTANCE_ID: intELIGIBLE_LEADERS_NOT_AVAILABLE: intELECTION_NOT_NEEDED: intNO_REASSIGNMENT_IN_PROGRESS: intGROUP_SUBSCRIBED_TO_TOPIC: intINVALID_RECORD: intUNSTABLE_OFFSET_COMMIT: intTHROTTLING_QUOTA_EXCEEDED: intPRODUCER_FENCED: intRESOURCE_NOT_FOUND: intDUPLICATE_RESOURCE: intUNACCEPTABLE_CREDENTIAL: intINCONSISTENT_VOTER_SET: intINVALID_UPDATE_VERSION: intFEATURE_UPDATE_FAILED: intPRINCIPAL_DESERIALIZATION_FAILURE: intSNAPSHOT_NOT_FOUND: intPOSITION_OUT_OF_RANGE: intUNKNOWN_TOPIC_ID: intDUPLICATE_BROKER_REGISTRATION: intBROKER_ID_NOT_REGISTERED: intINCONSISTENT_TOPIC_ID: intINCONSISTENT_CLUSTER_ID: intTRANSACTIONAL_ID_NOT_FOUND: int
KafkaProducer
Section titled “KafkaProducer”Produces records in batches; see the producer guide. Safe from any thread: every
method may be called from several threads at once, and a producer may be closed or
freed on a thread other than the one that made it. One transactional call runs at a
time - a different one made meanwhile returns an error marked _conflicting_use,
the same one from another thread _prev_in_progress, both retriable. Every blocking
call releases the GIL while it waits, and one made from error_cb, stats_cb or the
logger (which run on the producer’s own worker thread) raises ProduceError marked
_conflicting_use instead of blocking that thread on itself. A refused send raises
rather than returning an error, from produce* and the _sync variants alike: a
closed producer, an oversized record, a full queue (QueueFull), and an idempotent
producer that has failed fatally (ProduceError marked _producer_fatal; close it
and make a new one). The Either a _sync call returns carries delivery failures.
KafkaProducer(config: KafkaConfig)produce
Section titled “produce”produce(self, topic: str, value: Optional[bytes], key: Optional[bytes] = None, *, partition: int = -1, headers: Optional[dict[str, bytes] | IMap[str, bytes] | Sequence[tuple[str, bytes]]] = None, timestamp_ms: Optional[int] = None) -> ProduceReceiptproduce_many_bytes
Section titled “produce_many_bytes”produce_many_bytes(self, topic: str, values: BytesList | IList[bytes] | list[bytes], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> ProduceReceiptproduce_many_json
Section titled “produce_many_json”produce_many_json(self, topic: str, values: IList[dict] | list[dict], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> ProduceReceiptproduce_many_avro
Section titled “produce_many_avro”produce_many_avro(self, topic: str, values: IList[dict] | list[dict], serde: AvroSerde, keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> ProduceReceiptproduce_many
Section titled “produce_many”produce_many(self, records: IList[KafkaRecord] | list[KafkaRecord]) -> ProduceReceiptproduce_many_bytes_sync
Section titled “produce_many_bytes_sync”produce_many_bytes_sync(self, topic: str, values: BytesList | IList[bytes] | list[bytes], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> Either[ProduceReport, KafkaError]produce_many_json_sync
Section titled “produce_many_json_sync”produce_many_json_sync(self, topic: str, values: IList[dict] | list[dict], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None) -> Either[ProduceReport, KafkaError]flush(self, timeout_ms: Optional[int] = None) -> Either[FlushReport, KafkaError]purge(self, in_queue: bool = True, in_flight: bool = True, blocking: bool = True) -> Either[int, KafkaError]init_transactions
Section titled “init_transactions”init_transactions(self, timeout_ms: Optional[int] = None) -> Either[None, KafkaError]begin_transaction
Section titled “begin_transaction”begin_transaction(self) -> Either[None, KafkaError]commit_transaction
Section titled “commit_transaction”commit_transaction(self, timeout_ms: Optional[int] = None) -> Either[None, KafkaError]abort_transaction
Section titled “abort_transaction”abort_transaction(self, timeout_ms: Optional[int] = None) -> Either[None, KafkaError]produce_many_bytes_txn
Section titled “produce_many_bytes_txn”produce_many_bytes_txn(self, topic: str, values: BytesList | IList[bytes] | list[bytes], keys: Optional[BytesList | IList[bytes] | list[bytes]] = None, partition: int = -1) -> ProduceReceiptproduce_many_records_txn
Section titled “produce_many_records_txn”produce_many_records_txn(self, records: IList[KafkaRecord] | list[KafkaRecord]) -> ProduceReceiptsend_offsets_to_transaction
Section titled “send_offsets_to_transaction”send_offsets_to_transaction(self, offsets: IMap[TopicPartition, int], consumer_group_metadata: ConsumerGroupMetadata | Option[ConsumerGroupMetadata], timeout_ms: Optional[int] = None) -> Either[None, KafkaError]list_topics
Section titled “list_topics”list_topics(self) -> Either[IList[str], KafkaError]metrics
Section titled “metrics”metrics(self) -> dict[str, int]close(self, timeout_ms: Optional[int] = None) -> NoneKafkaProducerConfig
Section titled “KafkaProducerConfig”Alias of KafkaConfig.
KafkaProducerConfig(bootstrap_servers: str, client_id: str = 'pyrula', acks: str | int = 'all', compression: str = 'none', partitioner: str = 'murmur2', linger_ms: int = 5, batch_size_bytes: int = 131072, batch_num_messages: int = 10000, sticky_partitioning_linger_ms: Optional[int] = None, max_in_flight_requests_per_connection: Optional[int] = None, topic_metadata_refresh_interval_ms: int = 300000, connect_in_background: bool = False, max_request_bytes: int = 1048576, coalesce_produce_requests: bool = False, raw_connections_per_broker: int = 8, enable_idempotence: Optional[bool] = None, message_timeout_ms: Optional[int] = None, request_timeout_ms: int = 30000, retry_backoff_ms: int = 100, message_send_max_retries: int = 2147483647, queue_buffering_max_messages: int = 100000, queue_buffering_max_kbytes: int = 1048576, transactional_id: str = '', security_protocol: str = 'PLAINTEXT', sasl_mechanism: str = 'PLAIN', sasl_username: Optional[str] = None, sasl_password: Optional[str] = None, oauth_cb: Optional[Callable[[], tuple[str, float] | tuple[str, float, Optional[str]] | tuple[str, float, Optional[str], Optional[dict[str, str]]]]] = None, ssl_ca_location: Optional[str] = None, ssl_certificate_location: Optional[str] = None, ssl_key_location: Optional[str] = None, error_cb: Optional[Callable[[Exception], None]] = None, logger: Optional[logging.Logger] = None, statistics_interval_ms: int = 0, stats_cb: Optional[Callable[[dict[str, int]], None]] = None, extra: Any = ...)Fields:
bootstrap_servers: strclient_id: stracks: str | intcompression: strpartitioner: strlinger_ms: intbatch_size_bytes: intbatch_num_messages: intsticky_partitioning_linger_ms: Optional[int]max_in_flight_requests_per_connection: Optional[int]topic_metadata_refresh_interval_ms: intconnect_in_background: boolmax_request_bytes: intcoalesce_produce_requests: boolraw_connections_per_broker: intenable_idempotence: Optional[bool]message_timeout_ms: Optional[int]request_timeout_ms: intretry_backoff_ms: intmessage_send_max_retries: intqueue_buffering_max_messages: intqueue_buffering_max_kbytes: inttransactional_id: strsecurity_protocol: strsasl_mechanism: strsasl_username: Optional[str]sasl_password: Optional[str]oauth_cb: Optional[Callable[[], tuple[str, float] | tuple[str, float, Optional[str]] | tuple[str, float, Optional[str], Optional[dict[str, str]]]]]ssl_ca_location: Optional[str]ssl_certificate_location: Optional[str]ssl_key_location: Optional[str]error_cb: Optional[Callable[[Exception], None]]logger: Optional[logging.Logger]statistics_interval_ms: intstats_cb: Optional[Callable[[dict[str, int]], None]]extra: Any
KafkaRecord
Section titled “KafkaRecord”-1 on the produce path means route by key (round-robin without one); consumed records always carry their partition.
KafkaRecord(topic: str, value: Optional[bytes], partition: int = -1, offset: int = -1, key: Option[bytes] | bytes | None = ..., headers: Optional[dict[str, bytes] | IMap[str, bytes] | Sequence[tuple[str, bytes]]] = ..., timestamp_ms: Option[int] | int | None = ...)Fields:
topic: strvalue: Optional[bytes]partition: intoffset: intkey: Option[bytes]headers: IMap[str, bytes]header_list: list[tuple[str, bytes]]timestamp_ms: Option[int]
ListOffsetsResultInfo
Section titled “ListOffsetsResultInfo”ListOffsetsResultInfo(offset: int, timestamp_ms: int)Fields:
offset: inttimestamp_ms: int
MaxPollIntervalExceeded
Section titled “MaxPollIntervalExceeded”NewPartitions
Section titled “NewPartitions”NewPartitions(topic: str, total_count: int)Fields:
topic: strtotal_count: int
OffsetSpec
Section titled “OffsetSpec”OffsetSpec(kind: str, timestamp_ms: int = -1)Fields:
kind: strtimestamp_ms: int
earliest
Section titled “earliest”earliest(cls) -> OffsetSpeclatest
Section titled “latest”latest(cls) -> OffsetSpecmax_timestamp
Section titled “max_timestamp”max_timestamp(cls) -> OffsetSpecfor_timestamp
Section titled “for_timestamp”for_timestamp(cls, timestamp_ms: int) -> OffsetSpecPackedBytesBatch
Section titled “PackedBytesBatch”PackedBytesBatch(packed: bytes, offsets: IMap[TopicPartition, int], count: int)Fields:
packed: bytesoffsets: IMap[TopicPartition, int]count: int
to_bytes_list
Section titled “to_bytes_list”to_bytes_list(self) -> BytesListPartitionMetadata
Section titled “PartitionMetadata”PartitionMetadata(partition_index: int, leader_id: int, replicas: IList[int] = ..., isr: IList[int] = ..., error_code: Optional[int] = None)Fields:
partition_index: intleader_id: intreplicas: IList[int]isr: IList[int]error_code: Optional[int]
PollError
Section titled “PollError”ProduceError
Section titled “ProduceError”Fields:
report: ProduceReportdelivered: intfailed: int
ProduceReceipt
Section titled “ProduceReceipt”get(self) -> Either[ProduceReport, KafkaError]wait(self) -> Either[ProduceReport, KafkaError]try_get
Section titled “try_get”try_get(self) -> Optional[Either[ProduceReport, KafkaError]]ProduceReport
Section titled “ProduceReport”ProduceReport(accepted: int, delivered: int, failed: int, errors: list[ProduceError] = ..., deliveries: Deliveries = ...)Fields:
accepted: intdelivered: intfailed: interrors: list[ProduceError]deliveries: Deliveries
QueueFull
Section titled “QueueFull”RebalanceError
Section titled “RebalanceError”ResourceType
Section titled “ResourceType”Fields:
UNKNOWN: intTOPIC: intBROKER: int
TopicDescription
Section titled “TopicDescription”Alias of TopicMetadata.
TopicDescription(name: str, partitions: IList[PartitionMetadata] = ..., is_internal: bool = False, error: Optional[str] = None, error_code: Optional[int] = None)Fields:
name: strpartitions: IList[PartitionMetadata]is_internal: boolerror: Optional[str]error_code: Optional[int]
TopicMetadata
Section titled “TopicMetadata”TopicMetadata(name: str, partitions: IList[PartitionMetadata] = ..., is_internal: bool = False, error: Optional[str] = None, error_code: Optional[int] = None)Fields:
name: strpartitions: IList[PartitionMetadata]is_internal: boolerror: Optional[str]error_code: Optional[int]
TopicPartition
Section titled “TopicPartition”TopicPartition(topic: str, partition: int)Fields:
topic: strpartition: int
TopicPartitionInfo
Section titled “TopicPartitionInfo”Alias of PartitionMetadata.
TopicPartitionInfo(partition_index: int, leader_id: int, replicas: IList[int] = ..., isr: IList[int] = ..., error_code: Optional[int] = None)Fields:
partition_index: intleader_id: intreplicas: IList[int]isr: IList[int]error_code: Optional[int]
TopicResult
Section titled “TopicResult”TopicResult(name: str, error: str = '', code: int = 0, message: Optional[str] = None)Fields:
name: strerror: strcode: intmessage: Optional[str]
TopicSpec
Section titled “TopicSpec”TopicSpec(name: str, num_partitions: int = 1, replication_factor: int = 1, config: IMap[str, str] = ...)Fields:
name: strnum_partitions: intreplication_factor: intconfig: IMap[str, str]
Constants
Section titled “Constants”CAPABILITIES: tuple[str, ...]CAPABILITY_DEFINITIONS: dict[str, str]GUARANTEES: dict[str, Guarantee]- see the client guarantee matrixOFFSET_BEGINNING: intOFFSET_END: intOFFSET_INVALID: intOFFSET_STORED: int
Functions
Section titled “Functions”avro_schema_dict
Section titled “avro_schema_dict”avro_schema_dict(model: type, *, name: Optional[str] = None) -> dictavro_schema_json
Section titled “avro_schema_json”avro_schema_json(schema: Any) -> strconsume
Section titled “consume”consume(consumer: KafkaConsumer, *, max_records: int = 500, timeout_ms: int = 500) -> Generator[KafkaRecord]Convenience generator: yields KafkaRecord objects one at a time.
Usage: for record in consume(consumer, max_records=100): process(record)
Stops only on StopIteration (never blocks forever); caller must break out.
is_schema_type
Section titled “is_schema_type”is_schema_type(t: Any) -> booljson_schema_json
Section titled “json_schema_json”json_schema_json(schema: Any) -> str