moonkafka

    Open-source Apache Kafka client driver written in pure MoonBit

    Kafka
    streaming
    Download zip
    Author
    Version
    0.2.1
    License
    MIT
    Last updated
    7 days ago
    Downloads
    15

    Dependencies

    #moonkafka

    An open-source Apache Kafka client driver written in MoonBit.

    Target: Apache Kafka 4.x only.

    This driver deliberately supports only the latest Kafka generation — KRaft-based clusters (no ZooKeeper), the modern Kafka protocol, and no legacy broker/version compatibility baggage.

    Status: targeted for 0.2.0 — the transport + data-plane feature set is implemented and covered by a 200+ test suite (unit, mock-broker, golden fixtures) plus an optional real-cluster integration harness. The API may still change before 1.0.

    #Why MoonBit + Kafka?

    • MoonBit compiles to small, fast WebAssembly (and native) targets, making it a good fit for lightweight producers/consumers in edge, serverless, and embedded environments.
    • Kafka 4.x is a clean protocol baseline: by dropping ZooKeeper-era and pre-4.x compatibility, the driver stays small and easy to reason about.

    #Features

    Working today:

    • Kafka wire protocol codecs (compact types, zig-zag varints, tagged fields)
    • Per-request API version negotiation against the broker's advertised ranges
    • RecordBatch v2 (CRC32C-verified): record headers, control/transactional flags, read_committed filtering primitive, incremental batch builder, and whole-batch decompression for gzip, snappy, lz4, and zstd
    • Data-plane APIs: Produce v12/v13 (topic-id addressing, per-record errors), Fetch v12-v16 with incremental fetch sessions (KIP-227), Metadata v12/v13, DescribeTopicPartitions v0 (paginated), ListOffsets v10/v11, FindCoordinator v4 (batched)
    • Cluster layer: shared connection pool keyed by node id, metadata caching with expiry/error-triggered refresh, topic-id map, coordinator lookups
    • Simple producer: per-leader connections, partitioner strategies (Kafka- compatible murmur2 key-partitioning; sticky batching or round-robin for keyless messages; per-send manual partition override), record batching with linger/batch-size/buffer-memory accounting, a background sender task (pipelined Produce requests per leader, acks 0/1/-1, retries with backoff bounded by delivery timeout), metadata refresh on leadership changes, REBOOTSTRAP_REQUIRED recovery
    • Producer API: send, per-record SendHandles (await/cancel/ on_complete), batched send_all, and on-demand metrics (queue depth, in-flight, sent/failed counters, broker throttle time)
    • Idempotent producer (acks=all default): InitProducerId handshake, per-partition sequence stamping with rewind on failure, epoch bump on UNKNOWN_PRODUCER_ID
    • Transactions: transactional_id config with coordinator init, begin_transaction/commit_transaction/abort_transaction, AddPartitionsToTxn before produce, transactional offset commits (AddOffsetsToTxn + TxnOffsetCommit), EndTxn with epoch adoption, coordinator retry/refind, fencing detection, and abort-on-error commit policy
    • Simple consumer: concurrent per-leader fetches with incremental sessions and eviction recovery, offset resolution by sentinel or timestamp, the seek family (explicit/timestamp/beginning/end), committed-offset tracking with sync/async commit and autocommit (interval + commit-on-close), max_poll_records / max_partition_fetch_bytes caps, per-partition pause/resume, auto-offset-reset policies, leader-epoch truncation detection, and read_committed filtering of aborted transactions
    • KIP-848 consumer groups (primary path): ConsumerGroupHeartbeat membership with client-generated member ids, server-driven assignment applied atomically around rebalance listener hooks, static membership, regex subscription, graceful leave, and fencing recovery
    • Consumer surface: subscribe/assign split, position/committed/ assignment/group_metadata introspection, max_poll_interval_ms enforcement, and utf8 record helpers
    • Classic consumer groups (compat path): JoinGroup/SyncGroup/Heartbeat with range, round-robin, sticky, and cooperative-sticky assignors (two-round incremental rebalancing), static membership, graceful leave, and rebalance listener hooks
    • group_protocol selection: KIP-848 (default), classic, or fallback ordering probed against the broker's advertised APIs
    • Admin client: topics (create/delete/partitions/records/offset-delete), configs, ACLs, quotas, SCRAM credentials, log dirs, leaders, reassignments, cluster/controller introspection, transactions, and groups listing/describe/delete — with a shared retriable-result retry policy and paginated DescribeTopicPartitions walking
    • Share groups (KIP-932): ShareConsumer over ShareGroupHeartbeat v1 membership, ShareFetch v2 acquisition with delivery-count caps, and ShareAcknowledge v2 (accept/release/reject/renew); Describe/Alter/ DeleteShareGroupOffsets admin ops
    • Telemetry (KIP-714): GetTelemetrySubscriptions/PushTelemetry client driving a pluggable metrics provider (e.g. the driver's own counters)
    • Pipelined broker connections: request timeouts, in-flight cap, reconnect through bootstrap servers, broker throttling
    • TLS (including verified certificates via a custom CA) and SASL (PLAIN, SCRAM-SHA-256/512, OAUTHBEARER)

    #Requirements

    • MoonBit toolchain (latest stable)
    • An Apache Kafka 4.x cluster (KRaft mode). Older brokers are not supported and will not be.

    #Installation

    moon add daqing/moonkafka

    #Quick start

    ///|
    async fn main {
    // Produce
    let producer = @moonkafka.Producer::connect(
    host="127.0.0.1",
    port=9092,
    topic="events",
    )
    defer producer.close()
    let offset = producer.send(
    key=@utf8.encode("k1"),
    value=@utf8.encode("hello"),
    )
    println("produced at offset \{offset}")

    // Consume
    let consumer = @moonkafka.Consumer::connect(
    host="127.0.0.1",
    port=9092,
    topic="events",
    start_from=@moonkafka.StartFrom::Earliest,
    )
    defer consumer.close()
    for ;; {
    for record in consumer.poll() {
    println("offset=\{record.offset} value=\{record.value}")
    }
    }
    }

    A runnable example lives in cmd/main — it consumes all partitions of a topic and prints records until interrupted:

    moon run cmd/main -- consume events [host] [port]

    It can also produce a single message:

    moon run cmd/main -- produce events "hello" [key] [host] [port]

    Note: the socket layer is native-backend only (moonbitlang/async), so the module targets native.

    #Development

    moon test # unit + mock-broker (fake broker) suite make fmt # format code make info # regenerate package interfaces (.mbti) make integration # Kafka 4.3 (docker or podman) + real-client smoke test make bench # produce/consume throughput (needs a broker) make docker-up # start a KRaft cluster (make docker-up MULTI=1 for 3 nodes)

    Full harness guide: docs/5-testing.md. Protocol notes: version negotiation, consumer groups, transactions.

    #License

    MetricsProvider

    type MetricsProvider = () -> Bytes

    The pluggable metrics source: renders the driver's counters into the opaque payload pushed to the broker (a Plain-Text/OTLP-style render is up to the provider).

    BrokerError

    pub(all) suberror BrokerError {
    BrokerError(Int, String)
    }

    An error code reported by a broker in a response. message carries call-site context (which request, which topic/partition) on top of the protocol-level code.

    BrokerError::is_retriable

    fn BrokerError::is_retriable(self : BrokerError) -> Bool

    Whether the protocol marks this error as retriable.

    BrokerError::name

    fn BrokerError::name(self : BrokerError) -> String

    Protocol name for the error code, e.g. "OFFSET_OUT_OF_RANGE".

    ProtocolError

    pub(all) suberror ProtocolError {
    ProtocolError(String)
    BufferExhausted(String)
    }

    SaslError

    pub(all) suberror SaslError {
    SaslError(String)
    }

    SASL negotiation or authentication failure. The connection is closed.

    TransportError

    pub(all) suberror TransportError {
    ConnectionClosed(String)
    RequestTimeout(String)
    }

    Transport-level failure. The affected connection has been closed when either variant is raised; callers reconnect rather than retry in place.

    AbortedTx

    pub(all) struct AbortedTx {
    producer_id : Int64
    first_offset : Int64
    } derive(
    Debug
    )

    One entry of a Fetch response's aborted-transactions list.

    AclBinding

    pub(all) struct AclBinding {
    resource_type : Int
    resource_name : String
    pattern_type : Int
    principal : String
    host : String
    operation : Int
    permission_type : Int
    } derive(
    Debug
    )

    One ACL binding: who may do what with which resource from where.

    AclCreation

    pub(all) struct AclCreation {
    resource_type : Int
    resource_name : String
    pattern_type : Int
    principal : String
    host : String
    operation : Int
    permission_type : Int
    } derive(
    Debug
    )

    One ACL to create.

    AclDescription

    pub(all) struct AclDescription {
    principal : String
    host : String
    operation : Int
    permission_type : Int
    } derive(
    Debug
    )

    One ACL of a described resource.

    AclFilter

    pub(all) struct AclFilter {
    resource_type : Int
    resource_name : String?
    pattern_type : Int
    principal : String?
    host : String?
    operation : Int
    permission_type : Int
    } derive(
    Debug
    )

    Filter describing which ACLs to list or delete: a None field matches anything; ANY/MATCH enum values widen the match.

    Admin

    pub struct Admin {
    request_timeout_ms : Int
    admin_retries : Int
    retry_backoff_ms : Int
    retry_backoff_max_ms : Int
    closed : Bool
    // private fields
    }

    Admin::alter_client_quotas

    async fn Admin::alter_client_quotas(self : Admin, entries : Array[ClientQuotaAlteration], validate_only? : Bool) -> Array[AlterClientQuotasResult]

    Alter the quota config of the given entities; one result per entry.

    Admin::alter_configs

    async fn Admin::alter_configs(self : Admin, resources : Array[SettableConfigResource], validate_only? : Bool) -> Array[AlterConfigsResult]

    Legacy full-replace config alter: the given configs replace the resource's dynamic config set. Prefer incremental_alter_configs.

    Admin::alter_partition_reassignments

    async fn Admin::alter_partition_reassignments(self : Admin, topics : Array[ReassignableTopic], allow_replication_factor_change? : Bool) -> AdminReassignmentResult

    Move partitions onto new replica sets; a None replica list cancels a pending reassignment.

    Admin::alter_share_group_offsets

    async fn Admin::alter_share_group_offsets(self : Admin, group_id : String, topics : Array[ShareOffsetAlterTopic]) -> ShareOffsetAlterResult

    Set share-group partition start offsets. Per-partition error codes come back as values; a retriable top-level error re-issues the call.

    Admin::alter_user_scram

    async fn Admin::alter_user_scram(self : Admin, deletions : Array[ScramCredentialDeletion], upsertions : Array[ScramCredentialUpsertion]) -> Array[AlterUserScramResult]

    Delete and upsert SCRAM credentials; one result per affected user.

    Admin::close

    fn Admin::close(self : Admin) -> Unit

    Close the admin client and tear its connections down.

    Admin::connect

    async fn Admin::connect(host~ : String, port~ : Int) -> Admin

    Connect the admin client: one bootstrap negotiation, metadata cached like the other clients. Ops run on any broker or on the controller as each API requires. Admin runs no background tasks of its own, so it takes no task group (unlike the producer/consumer clients).

    Admin::connect_with_config

    async fn Admin::connect_with_config(config : AdminConfig) -> Admin

    Admin::create_acls

    async fn Admin::create_acls(self : Admin, creations : Array[AclCreation]) -> Array[CreateAclsResult]

    Create ACL bindings; one result per creation.

    Admin::create_partitions

    async fn Admin::create_partitions(self : Admin, topics : Array[CreatePartitionsSpec], validate_only? : Bool) -> Array[CreatePartitionsResult]

    Grow topics to new partition counts, optionally with explicit replica placement for the new partitions.

    Admin::create_topics

    async fn Admin::create_topics(self : Admin, topics : Array[CreatableTopic], validate_only? : Bool) -> Array[CreateTopicsResult]

    Create topics: configs and replica assignments per topic, results per topic. Retriable per-topic errors re-issue under the policy.

    Admin::delete_acls

    async fn Admin::delete_acls(self : Admin, filters : Array[AclFilter]) -> Array[DeleteAclsFilterResult]

    Delete every ACL matching each filter; one result per filter with the matched bindings.

    Admin::delete_groups

    async fn Admin::delete_groups(self : Admin, groups : Array[String]) -> Array[AdminDeletedGroup]

    Delete the given consumer groups. Each requested group comes back with its own error code as a value (0 = deleted, NON_EMPTY_GROUP if it still has members, GROUP_ID_NOT_FOUND if unknown); a retriable per-group error re-issues the whole call under the retry policy. The broker forwards to the group coordinator, so the call runs on any broker.

    Admin::delete_records

    async fn Admin::delete_records(self : Admin, topics : Array[(String, Array[(Int, Int64)])]) -> Array[DeleteRecordsResult]

    Delete records up to the given offsets; results carry the new low watermarks.

    Admin::delete_share_group_offsets

    async fn Admin::delete_share_group_offsets(self : Admin, group_id : String, topics : Array[String]) -> ShareOffsetDeleteResult

    Delete the committed share offsets of the given topics for a group.

    Admin::delete_topics

    async fn Admin::delete_topics(self : Admin, names : Array[String], topic_ids : Array[Uuid]) -> Array[DeleteTopicsResult]

    Delete topics by name, by topic id, or mixed (topic-id-first when only an id is given).

    Admin::describe_acls

    async fn Admin::describe_acls(self : Admin, filter : AclFilter) -> DescribeAclsResult

    List the ACLs matching the filter (an all-ANY filter with null fields lists everything). Retriable errors re-issue under the policy.

    Admin::describe_client_quotas

    async fn Admin::describe_client_quotas(self : Admin, filter : ClientQuotaFilter) -> DescribeClientQuotasResult

    List the quota entities matching the filter (an empty component list matches everything). Retriable errors re-issue under the policy.

    Admin::describe_cluster

    async fn Admin::describe_cluster(self : Admin, include_authorized_operations? : Bool, include_fenced_brokers? : Bool) -> AdminClusterDescription

    Describe the cluster: brokers, controller, cluster id. Served by any broker; include_fenced_brokers only applies at v2.

    Admin::describe_configs

    async fn Admin::describe_configs(self : Admin, resources : Array[ConfigResourceKey]) -> Array[AdminConfigsResult]

    Describe configs of the given resources (topics, brokers, broker loggers, client-metrics, groups). Retriable per-resource errors re-issue under the policy.

    Admin::describe_consumer_groups

    async fn Admin::describe_consumer_groups(self : Admin, group_ids : Array[String], include_authorized_operations? : Bool) -> Array[AdminConsumerGroupDescription]

    Describe KIP-848 consumer groups: state, epochs, assignor, and members with their subscriptions, current assignments, and target assignments. One description per requested group, in request order, with per-group error codes as values.

    This is the call for new-protocol groups; describe_groups reports GROUP_ID_NOT_FOUND for them.

    Admin::describe_groups

    async fn Admin::describe_groups(self : Admin, groups : Array[String], include_authorized_operations? : Bool) -> Array[AdminGroupDescription]

    Describe classic consumer groups: state, protocol, and members with their subscriptions and assignments. One description per requested group, in request order, with per-group error codes as values.

    A KIP-848 consumer group comes back with is_not_found() true and state "Dead" — DescribeGroups only describes classic groups; use ConsumerGroupDescribe for the new protocol.

    Admin::describe_log_dirs

    async fn Admin::describe_log_dirs(self : Admin, topics? : Array[(String, Array[Int])]?) -> AdminLogDirs

    Describe the broker log directories: per-dir partitions, sizes, lag, volume capacity, and the cordon state. topics None asks for all.

    Admin::describe_producers

    async fn Admin::describe_producers(self : Admin, topics : Array[(String, Array[Int])]) -> Array[AdminDescribeProducersTopic]

    Describe the active producers of the given topic partitions: each partition reports the producers currently holding it with their id, epoch, last sequence/timestamp, and the offset their current transaction started at. Per-partition error codes travel as values and a retriable one re-issues the whole call under the retry policy. Partition leaders answer, so the call runs on any broker.

    Admin::describe_quorum

    async fn Admin::describe_quorum(self : Admin, topic? : String, partition? : Int) -> AdminQuorumDescription

    Describe the metadata quorum: leader, high watermark, and voter progress. Defaults to the cluster metadata partition.

    Admin::describe_share_group_offsets

    async fn Admin::describe_share_group_offsets(self : Admin, group_id : String, topics : Array[ShareOffsetDescribeTopic]) -> Array[ShareOffsetDescribeGroupResult]

    Describe share-group offsets for one group, optionally narrowed to a set of topics (empty describes all topic-partitions). Retriable group errors re-issue the whole call under the admin retry policy.

    Admin::describe_topic_partitions

    async fn Admin::describe_topic_partitions(self : Admin, topics : Array[String]) -> Array[AdminTopicDescription]

    Inspect topic partitions: names, ids, leaders, replicas — the paginated DescribeTopicPartitions v0 walkthrough (all pages followed). Per-topic error codes come back as values; a retriable topic error re-issues the whole call under the retry policy.

    Admin::describe_transactions

    async fn Admin::describe_transactions(self : Admin, transactional_ids : Array[String]) -> Array[AdminDescribeTransaction]

    Describe the given transactional ids: their current state, timeout, start time, producer id/epoch, and the topic-partitions the transaction currently spans. Per-id error codes travel as values and a retriable one re-issues the whole call under the retry policy. The transaction coordinator answers, so the broker forwards and the call runs on any broker.

    Admin::describe_user_scram

    async fn Admin::describe_user_scram(self : Admin, users : Array[String]?) -> DescribeUserScramResult

    Describe the SCRAM credentials of the given users (None = every user with credentials); one result per user.

    Admin::elect_leaders

    async fn Admin::elect_leaders(self : Admin, election_type : Int, topic_partitions? : Array[(String, Array[Int])]?) -> AdminElectionResult

    Request leader elections (preferred or unclean) for the given topic partitions; None elects for every partition.

    Admin::incremental_alter_configs

    async fn Admin::incremental_alter_configs(self : Admin, resources : Array[AlterableConfigResource], validate_only? : Bool) -> Array[AlterConfigsResult]

    Apply incremental config updates (set/delete/append/subtract per key), the alter path that preserves unknown configs.

    Admin::list_config_resources

    async fn Admin::list_config_resources(self : Admin, resource_types? : Array[Int]) -> ListConfigResourcesResult

    List the broker's config resources, optionally filtered by type.

    Admin::list_groups

    async fn Admin::list_groups(self : Admin, states_filter? : Array[String], types_filter? : Array[String]) -> AdminListGroupsResult

    List the groups a cluster's brokers know about, optionally filtered by group state and group type (empty filters mean "all"). ListGroups is answered only from the state each broker holds itself, so the call fans out to every broker in the cached metadata snapshot and merges the results, de-duplicating groups shared across brokers. The returned error is the first non-zero error any broker reported; retriable ones re-issue the whole call under the retry policy. Transport failures raise.

    Admin::list_partition_reassignments

    async fn Admin::list_partition_reassignments(self : Admin, topics? : Array[(String, Array[Int])]?) -> AdminOngoingReassignments

    List ongoing partition reassignments, optionally filtered by topic.

    Admin::list_transactions

    async fn Admin::list_transactions(self : Admin, state_filters? : Array[String], producer_id_filters? : Array[Int64], duration_filter? : Int64, transactional_id_pattern? : String?) -> AdminListTransactionsResult

    List the transactions a cluster's brokers coordinate, optionally filtered by state, producer id, minimum duration, and transactional-id pattern (empty/None filters mean "all"). Like ListGroups, the broker answers only from its own coordinator state, so the call fans out to every broker in the cached metadata snapshot and merges the results, de-duplicating transactions seen on multiple brokers and unioning the unknown-filter echoes. The returned error is the first non-zero error any broker reported; retriable ones re-issue the whole call under the retry policy. Transport failures raise.

    Admin::offset_delete

    async fn Admin::offset_delete(self : Admin, group_id : String, topics : Array[(String, Array[Int])]) -> OffsetDeleteResult

    Delete committed offsets of a consumer group for the given topic partitions.

    Admin::unregister_broker

    async fn Admin::unregister_broker(self : Admin, broker_id : Int) -> UnregisterBrokerResult

    Unregister a fenced broker from the cluster (controller-routed).

    Admin::update_features

    async fn Admin::update_features(self : Admin, updates : Array[FeatureUpdate], validate_only? : Bool) -> AdminUpdateFeaturesResult

    Update finalized feature levels (upgrade, safe/unsafe downgrade, or delete with a level < 1).

    AdminActiveProducer

    pub struct AdminActiveProducer {
    producer_id : Int64
    producer_epoch : Int
    last_sequence : Int
    last_timestamp : Int64
    coordinator_epoch : Int
    current_txn_start_offset : Int64
    } derive(
    Debug
    )

    One active producer for a partition, as DescribeProducers reports it.

    AdminAssignedTopicPartitions

    pub struct AdminAssignedTopicPartitions {
    topic_id : Uuid
    topic_name : String
    partitions : Array[Int]
    } derive(
    Debug
    )

    One topic's partitions inside a member's assignment.

    AdminClusterBroker

    pub(all) struct AdminClusterBroker {
    node_id : Int
    host : String
    port : Int
    rack : String?
    is_fenced : Bool
    } derive(
    Debug
    )

    One cluster broker of a DescribeCluster result.

    AdminClusterDescription

    pub struct AdminClusterDescription {
    error_code : Int
    error_message : String?
    endpoint_type : Int
    cluster_id : String?
    controller_id : Int
    brokers : Array[AdminClusterBroker]
    cluster_authorized_operations : Int
    } derive(
    Debug
    )

    AdminConfig

    pub struct AdminConfig {
    common : CommonConfig
    admin_retries : Int
    } derive(
    Debug
    )

    Admin client settings on top of the shared transport config. The retry knob is admin-specific: broker-side retriable errors (not controller available, leader elections in flight, ...) re-issue the whole call.

    AdminConfig::new

    fn AdminConfig::new(bootstrap_servers : Array[String], request_timeout_ms? : Int, security_protocol? : SecurityProtocol, sasl? : SaslConfig?, tls? : TlsClientOptions?, metadata_max_age_ms? : Int, admin_retries? : Int) -> AdminConfig raise

    AdminConfigEntry

    pub(all) struct AdminConfigEntry {
    name : String
    value : String?
    read_only : Bool
    config_source : Int
    is_sensitive : Bool
    synonyms : Array[(String, String?, Int)]
    config_type : Int
    documentation : String?
    } derive(
    Debug
    )

    One described config entry with its source and synonyms.

    AdminConfigsResult

    pub struct AdminConfigsResult {
    error_code : Int
    error_message : String?
    resource_type : Int
    resource_name : String
    configs : Array[AdminConfigEntry]
    } derive(
    Debug
    )

    AdminConsumerGroupDescription

    pub struct AdminConsumerGroupDescription {
    error_code : Int
    error_message : String?
    group_id : String
    group_state : String
    group_epoch : Int
    assignment_epoch : Int
    assignor_name : String
    members : Array[AdminConsumerGroupMember]
    authorized_operations : Int?
    } derive(
    Debug
    )

    One group's ConsumerGroupDescribe result (error codes as values).

    AdminConsumerGroupMember

    pub struct AdminConsumerGroupMember {
    member_id : String
    instance_id : String?
    rack_id : String?
    member_epoch : Int
    client_id : String
    client_host : String
    subscribed_topic_names : Array[String]
    subscribed_topic_regex : String?
    assignment : Array[AdminAssignedTopicPartitions]
    target_assignment : Array[AdminAssignedTopicPartitions]
    member_type : Int
    } derive(
    Debug
    )

    One member of a KIP-848 consumer group.

    AdminDeletedGroup

    pub struct AdminDeletedGroup {
    group_id : String
    error_code : Int
    } derive(
    Debug
    )

    One group's DeleteGroups v2 result (error codes as values).

    AdminDescribeProducerPartition

    pub struct AdminDescribeProducerPartition {
    partition_index : Int
    error_code : Int
    error_message : String?
    active_producers : Array[AdminActiveProducer]
    } derive(
    Debug
    )

    One partition's DescribeProducers result (error codes as values).

    AdminDescribeProducersTopic

    pub struct AdminDescribeProducersTopic {
    name : String
    partitions : Array[AdminDescribeProducerPartition]
    } derive(
    Debug
    )

    One topic's DescribeProducers result.

    AdminDescribeTransaction

    pub struct AdminDescribeTransaction {
    error_code : Int
    transactional_id : String
    transaction_state : String
    transaction_timeout_ms : Int
    transaction_start_time_ms : Int64
    producer_id : Int64
    producer_epoch : Int
    topics : Array[AdminTransactionTopic]
    } derive(
    Debug
    )

    One transactional id's DescribeTransactions result (error codes as values). topics is empty once the transaction is no longer active.

    AdminElectionResult

    pub struct AdminElectionResult {
    error_code : Int
    results : Array[ElectLeadersTopicResult]
    } derive(
    Debug
    )

    AdminGroupDescription

    pub struct AdminGroupDescription {
    error_code : Int
    error_message : String?
    group_id : String
    group_state : String
    protocol_type : String
    protocol_data : String
    members : Array[AdminGroupMember]
    authorized_operations : Int?
    } derive(
    Debug
    )

    One group's DescribeGroups result (error codes as values).

    AdminGroupDescription::is_not_found

    fn AdminGroupDescription::is_not_found(self : AdminGroupDescription) -> Bool

    True when the broker could not describe the group because it is not a classic group — the KIP-848 consumer-group case, where v6 reports GROUP_ID_NOT_FOUND (69). Such a group needs ConsumerGroupDescribe.

    AdminGroupMember

    pub struct AdminGroupMember {
    member_id : String
    group_instance_id : String?
    client_id : String
    client_host : String
    member_metadata : Bytes
    member_assignment : Bytes
    } derive(
    Debug
    )

    One member of a described classic group.

    AdminGroupMember::assigned_partitions

    fn AdminGroupMember::assigned_partitions(self : AdminGroupMember) -> Array[(String, Array[Int])]

    The member's assigned partitions, decoded from member_assignment. Empty under the same conditions as subscribed_topics.

    AdminGroupMember::subscribed_topics

    fn AdminGroupMember::subscribed_topics(self : AdminGroupMember) -> Array[String]

    The member's subscribed topics, decoded from member_metadata. Empty when the broker sent no metadata (any state but Stable) or the payload is not the version-0 ConsumerProtocolSubscription this driver writes — a custom protocol's metadata is opaque, so read the raw bytes.

    AdminListGroupsResult

    pub struct AdminListGroupsResult {
    error_code : Int
    groups : Array[AdminListedGroup]
    } derive(
    Debug
    )

    One ListGroups result. Unlike DescribeGroups, the error is per-call: a single top-level error covers the whole listing, and groups is empty when it is non-zero.

    AdminListTransactionsResult

    pub struct AdminListTransactionsResult {
    error_code : Int
    unknown_state_filters : Array[String]
    transactions : Array[AdminListedTransaction]
    } derive(
    Debug
    )

    One ListTransactions result. The error is per-call: a single top-level error covers the whole listing, and transactions is empty when it is non-zero. unknown_state_filters echoes any request filters the coordinator did not recognize.

    AdminListedGroup

    pub struct AdminListedGroup {
    group_id : String
    protocol_type : String
    group_state : String
    group_type : String
    } derive(
    Debug
    )

    One group a broker listed in a ListGroups v5 response.

    AdminListedTransaction

    pub struct AdminListedTransaction {
    transactional_id : String
    producer_id : Int64
    transaction_state : String
    } derive(
    Debug
    )

    One transactional id listed by ListTransactions.

    AdminLogDirs

    pub struct AdminLogDirs {
    error_code : Int
    results : Array[LogDirResult]
    } derive(
    Debug
    )

    AdminOngoingReassignments

    pub struct AdminOngoingReassignments {
    error_code : Int
    error_message : String?
    topics : Array[(String, Array[OngoingPartitionReassignment])]
    } derive(
    Debug
    )

    AdminQuorumDescription

    pub struct AdminQuorumDescription {
    error_code : Int
    error_message : String?
    topics : Array[QuorumTopicState]
    nodes : Array[QuorumNode]
    } derive(
    Debug
    )

    AdminReassignmentResult

    pub struct AdminReassignmentResult {
    error_code : Int
    error_message : String?
    responses : Array[(String, Array[ReassignablePartitionResponse])]
    } derive(
    Debug
    )

    AdminTopicDescription

    pub struct AdminTopicDescription {
    name : String
    error_code : Int
    topic_id : Uuid
    partitions : Array[PartitionInfo]
    } derive(
    Debug
    )

    One topic's DescribeTopicPartitions result (error codes as values).

    AdminTransactionTopic

    pub struct AdminTransactionTopic {
    topic : String
    partitions : Array[Int]
    } derive(
    Debug
    )

    One topic and its partitions inside an in-flight transaction, as DescribeTransactions reports it.

    AdminUpdateFeaturesResult

    pub struct AdminUpdateFeaturesResult {
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    AlterClientQuotasResult

    pub struct AlterClientQuotasResult {
    error_code : Int
    error_message : String?
    entity : Array[QuotaEntity]
    } derive(
    Debug
    )

    AlterConfigsResult

    pub struct AlterConfigsResult {
    error_code : Int
    error_message : String?
    resource_type : Int
    resource_name : String
    } derive(
    Debug
    )

    AlterUserScramResult

    pub struct AlterUserScramResult {
    user : String
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    AlterableConfig

    pub(all) struct AlterableConfig {
    name : String
    operation : Int
    value : String?
    } derive(
    Debug
    )

    One incremental config update: an operation applied to one key.

    AlterableConfigResource

    pub(all) struct AlterableConfigResource {
    resource_type : Int
    resource_name : String
    configs : Array[AlterableConfig]
    } derive(
    Debug
    )

    One resource's incremental updates.

    ApiRange

    pub(all) struct ApiRange {
    key : Int
    name : String
    min : Int
    max : Int
    } derive(
    Debug
    )

    One row of the driver's version matrix: the contiguous range of versions whose codecs are implemented for one API.

    Assignee

    pub(all) struct Assignee {
    member_id : String
    topics : Array[String]
    } derive(
    Debug
    )

    One member's input to an assignment: its id and subscribed topics.

    Assignor

    pub(all) enum Assignor {
    RangeAssignor
    RoundRobinAssignor
    StickyAssignor
    CooperativeStickyAssignor
    } derive(Eq,
    Debug
    )

    Assignor::name

    fn Assignor::name(self : Assignor) -> String

    The wire protocol names the brokers and Java clients use.

    AutoOffsetReset

    pub(all) enum AutoOffsetReset {
    ResetEarliest
    ResetLatest
    ResetNone
    } derive(
    Debug
    )

    Where to move the read position when a fetch reports OFFSET_OUT_OF_RANGE (Java's auto.offset.reset). ResetNone surfaces the error to the caller instead of silently repositioning.

    Backoff

    pub struct Backoff {
    base_ms : Int
    max_ms : Int
    attempt : Int
    } derive(
    Debug
    )

    Stateful backoff schedule: next_ms() grows exponentially per call and applies ±20% wall-clock jitter so retried clients do not synchronize.

    Backoff::new

    fn Backoff::new(base_ms? : Int, max_ms? : Int) -> Backoff raise

    Backoff::next_ms

    fn Backoff::next_ms(self : Backoff) -> Int

    Next delay in milliseconds, advancing the attempt counter.

    Backoff::reset

    fn Backoff::reset(self : Backoff) -> Unit

    BootstrapServers

    pub struct BootstrapServers {
    addrs : Array[HostPort]
    cursor : Int
    } derive(
    Debug
    )

    Rotating view over parsed bootstrap server addresses.

    BootstrapServers::new

    fn BootstrapServers::new(addrs : Array[HostPort]) -> BootstrapServers raise

    BootstrapServers::next

    Next address in round-robin order.

    BrokerConnection

    pub struct BrokerConnection {
    tcp :
    Tcp

    stream : BrokerStream
    client_id : String
    write_lock :
    Mutex

    read_lock :
    Mutex

    responses : Map[Int, Bytes]
    correlation_id : Int
    closed : Bool
    in_flight :
    Semaphore

    throttled_until_ms : Int64
    throttle_total_ms : Int64
    versions : BrokerVersions?
    }

    BrokerConnection::add_offsets_to_txn

    async fn BrokerConnection::add_offsets_to_txn(self : BrokerConnection, transactional_id : String, producer_id : Int64, producer_epoch : Int, group_id : String, timeout_ms? : Int) -> Int

    BrokerConnection::add_partitions_to_txn

    async fn BrokerConnection::add_partitions_to_txn(self : BrokerConnection, transactional_id : String, producer_id : Int64, producer_epoch : Int, topics : Array[(String, Array[Int])], timeout_ms? : Int) -> Array[TxnPartitionResult]

    BrokerConnection::alter_client_quotas

    async fn BrokerConnection::alter_client_quotas(self : BrokerConnection, entries : Array[ClientQuotaAlteration], validate_only? : Bool, timeout_ms? : Int) -> Array[AlterClientQuotasResult]

    BrokerConnection::alter_configs

    async fn BrokerConnection::alter_configs(self : BrokerConnection, resources : Array[SettableConfigResource], timeout_ms? : Int, validate_only? : Bool) -> Array[AlterConfigsResult]

    BrokerConnection::alter_partition_reassignments

    async fn BrokerConnection::alter_partition_reassignments(self : BrokerConnection, topics : Array[ReassignableTopic], timeout_ms? : Int, allow_replication_factor_change? : Bool) -> AdminReassignmentResult

    BrokerConnection::alter_share_group_offsets

    async fn BrokerConnection::alter_share_group_offsets(self : BrokerConnection, group_id : String, topics : Array[ShareOffsetAlterTopic], timeout_ms? : Int) -> ShareOffsetAlterResult

    BrokerConnection::alter_user_scram

    async fn BrokerConnection::alter_user_scram(self : BrokerConnection, deletions : Array[ScramCredentialDeletion], upsertions : Array[ScramCredentialUpsertion], timeout_ms? : Int) -> Array[AlterUserScramResult]

    BrokerConnection::api_version

    fn BrokerConnection::api_version(self : BrokerConnection, api_key : Int, want? : Int?) -> Int raise

    Negotiated request version for one API on this connection: the highest version common to the driver matrix and the ranges the broker advertised at handshake time. Raises when the handshake has not run on this connection.

    BrokerConnection::authenticate

    async fn BrokerConnection::authenticate(self : BrokerConnection, sasl : SaslConfig, timeout_ms? : Int) -> Unit

    Run the SASL handshake and authentication exchange on an established connection. OAUTHBEARER and the SCRAM family raise until their implementations land.

    BrokerConnection::close

    fn BrokerConnection::close(self : BrokerConnection) -> Unit

    Close the underlying socket. Idempotent; later requests fail with ConnectionClosed, and in-flight ones fail as their reads break.

    BrokerConnection::connect

    async fn BrokerConnection::connect(host : String, port : Int, client_id? : String, max_in_flight? : Int, timeout_ms? : Int, tls? : TlsClientOptions?) -> BrokerConnection

    BrokerConnection::consumer_group_heartbeat

    async fn BrokerConnection::consumer_group_heartbeat(self : BrokerConnection, group_id : String, member_id : String, member_epoch : Int, instance_id? : String?, rebalance_timeout_ms? : Int, subscribed_topic_names? : Array[String]?, subscribed_topic_regex? : String?, server_assignor? : String?, timeout_ms? : Int) -> ConsumerGroupHeartbeatResult

    BrokerConnection::create_acls

    async fn BrokerConnection::create_acls(self : BrokerConnection, creations : Array[AclCreation], timeout_ms? : Int) -> Array[CreateAclsResult]

    BrokerConnection::create_partitions

    async fn BrokerConnection::create_partitions(self : BrokerConnection, topics : Array[CreatePartitionsSpec], timeout_ms : Int, validate_only? : Bool) -> Array[CreatePartitionsResult]

    BrokerConnection::create_topics

    async fn BrokerConnection::create_topics(self : BrokerConnection, topics : Array[CreatableTopic], timeout_ms : Int, validate_only? : Bool) -> Array[CreateTopicsResult]

    BrokerConnection::delete_acls

    async fn BrokerConnection::delete_acls(self : BrokerConnection, filters : Array[AclFilter], timeout_ms? : Int) -> Array[DeleteAclsFilterResult]

    BrokerConnection::delete_groups

    async fn BrokerConnection::delete_groups(self : BrokerConnection, groups : Array[String], timeout_ms? : Int) -> Array[AdminDeletedGroup]

    BrokerConnection::delete_records

    async fn BrokerConnection::delete_records(self : BrokerConnection, topics : Array[(String, Array[(Int, Int64)])], timeout_ms : Int) -> Array[DeleteRecordsResult]

    BrokerConnection::delete_share_group_offsets

    async fn BrokerConnection::delete_share_group_offsets(self : BrokerConnection, group_id : String, topics : Array[String], timeout_ms? : Int) -> ShareOffsetDeleteResult

    BrokerConnection::delete_topics

    async fn BrokerConnection::delete_topics(self : BrokerConnection, names : Array[String], topic_ids : Array[Uuid], timeout_ms : Int) -> Array[DeleteTopicsResult]

    BrokerConnection::describe_acls

    async fn BrokerConnection::describe_acls(self : BrokerConnection, filter : AclFilter, timeout_ms? : Int) -> DescribeAclsResult

    BrokerConnection::describe_client_quotas

    async fn BrokerConnection::describe_client_quotas(self : BrokerConnection, filter : ClientQuotaFilter, timeout_ms? : Int) -> DescribeClientQuotasResult

    BrokerConnection::describe_cluster

    async fn BrokerConnection::describe_cluster(self : BrokerConnection, include_authorized_operations? : Bool, include_fenced_brokers? : Bool, timeout_ms? : Int) -> AdminClusterDescription

    BrokerConnection::describe_configs

    async fn BrokerConnection::describe_configs(self : BrokerConnection, resources : Array[ConfigResourceKey], timeout_ms? : Int) -> Array[AdminConfigsResult]

    BrokerConnection::describe_consumer_groups

    async fn BrokerConnection::describe_consumer_groups(self : BrokerConnection, group_ids : Array[String], include_authorized_operations? : Bool, timeout_ms? : Int) -> Array[AdminConsumerGroupDescription]

    BrokerConnection::describe_groups

    async fn BrokerConnection::describe_groups(self : BrokerConnection, groups : Array[String], include_authorized_operations? : Bool, timeout_ms? : Int) -> Array[AdminGroupDescription]

    BrokerConnection::describe_log_dirs

    async fn BrokerConnection::describe_log_dirs(self : BrokerConnection, topics? : Array[(String, Array[Int])]?, timeout_ms? : Int) -> AdminLogDirs

    BrokerConnection::describe_producers

    async fn BrokerConnection::describe_producers(self : BrokerConnection, topics : Array[(String, Array[Int])], timeout_ms? : Int) -> Array[AdminDescribeProducersTopic]

    BrokerConnection::describe_quorum

    async fn BrokerConnection::describe_quorum(self : BrokerConnection, topics : Array[(String, Array[Int])], timeout_ms? : Int) -> AdminQuorumDescription

    BrokerConnection::describe_share_group_offsets

    async fn BrokerConnection::describe_share_group_offsets(self : BrokerConnection, groups : Array[ShareOffsetDescribeGroup], timeout_ms? : Int) -> Array[ShareOffsetDescribeGroupResult]

    BrokerConnection::describe_topic_partitions

    async fn BrokerConnection::describe_topic_partitions(self : BrokerConnection, topics : Array[String], response_partition_limit? : Int, cursor? : TopicPartitionCursor?, timeout_ms? : Int) -> DescribeTopicPartitions

    Describe topics via DescribeTopicPartitions v0, one page per call: returns the page plus the cursor to resume with when the broker truncated the response at response_partition_limit. An empty topics list describes all topics.

    BrokerConnection::describe_transactions

    async fn BrokerConnection::describe_transactions(self : BrokerConnection, transactional_ids : Array[String], timeout_ms? : Int) -> Array[AdminDescribeTransaction]

    BrokerConnection::describe_user_scram

    async fn BrokerConnection::describe_user_scram(self : BrokerConnection, users : Array[String]?, timeout_ms? : Int) -> DescribeUserScramResult

    BrokerConnection::elect_leaders

    async fn BrokerConnection::elect_leaders(self : BrokerConnection, election_type : Int, topic_partitions? : Array[(String, Array[Int])]?, timeout_ms? : Int) -> AdminElectionResult

    BrokerConnection::end_txn

    async fn BrokerConnection::end_txn(self : BrokerConnection, transactional_id : String, producer_id : Int64, producer_epoch : Int, committed : Bool, timeout_ms? : Int) -> EndTxnResult

    BrokerConnection::fetch

    async fn BrokerConnection::fetch(self : BrokerConnection, topics : Array[FetchTopicReq], session~ : FetchSessionReq, max_wait_ms~ : Int, min_bytes? : Int, max_bytes? : Int, isolation_level? : Int, timeout_ms? : Int) -> FetchResult

    Fetch records from one or more topics with fetch-session fields. The negotiated version shapes the wire format; the caller drives the session (FetchSession::prepare / handle_response) and owns recovery from session eviction.

    BrokerConnection::fetch_metadata

    async fn BrokerConnection::fetch_metadata(self : BrokerConnection, topics : Array[String]?, timeout_ms? : Int) -> Metadata

    BrokerConnection::find_coordinator

    async fn BrokerConnection::find_coordinator(self : BrokerConnection, keys : Array[String], coordinator_type : CoordinatorType, timeout_ms? : Int) -> Array[CoordinatorInfo]

    BrokerConnection::get_telemetry_subscriptions

    async fn BrokerConnection::get_telemetry_subscriptions(self : BrokerConnection, client_instance_id : Uuid, timeout_ms? : Int) -> (TelemetrySubscription, Int)

    BrokerConnection::group_heartbeat

    async fn BrokerConnection::group_heartbeat(self : BrokerConnection, group_id : String, generation_id : Int, member_id : String, group_instance_id? : String?, timeout_ms? : Int) -> Int

    BrokerConnection::incremental_alter_configs

    async fn BrokerConnection::incremental_alter_configs(self : BrokerConnection, resources : Array[AlterableConfigResource], timeout_ms? : Int, validate_only? : Bool) -> Array[AlterConfigsResult]

    BrokerConnection::init_producer_id

    async fn BrokerConnection::init_producer_id(self : BrokerConnection, transactional_id? : String?, transaction_timeout_ms? : Int, producer_id? : Int64, producer_epoch? : Int, timeout_ms? : Int) -> InitProducerIdResult

    BrokerConnection::join_group

    async fn BrokerConnection::join_group(self : BrokerConnection, group_id : String, session_timeout_ms : Int, rebalance_timeout_ms : Int, member_id : String, group_instance_id? : String?, protocols~ : Array[JoinGroupProtocol], timeout_ms? : Int) -> JoinGroupResult

    BrokerConnection::leave_group

    async fn BrokerConnection::leave_group(self : BrokerConnection, group_id : String, member_id : String, group_instance_id? : String?, timeout_ms? : Int) -> Int

    BrokerConnection::list_config_resources

    async fn BrokerConnection::list_config_resources(self : BrokerConnection, resource_types? : Array[Int], timeout_ms? : Int) -> ListConfigResourcesResult

    BrokerConnection::list_groups

    async fn BrokerConnection::list_groups(self : BrokerConnection, states_filter : Array[String], types_filter : Array[String], timeout_ms? : Int) -> AdminListGroupsResult

    BrokerConnection::list_offsets

    async fn BrokerConnection::list_offsets(self : BrokerConnection, topic : String, partitions : Array[PartitionInfo], timestamp : Int64, timeout_ms? : Int) -> Map[Int, Int64]

    BrokerConnection::list_partition_reassignments

    async fn BrokerConnection::list_partition_reassignments(self : BrokerConnection, topics? : Array[(String, Array[Int])]?, timeout_ms? : Int) -> AdminOngoingReassignments

    BrokerConnection::list_transactions

    async fn BrokerConnection::list_transactions(self : BrokerConnection, state_filters : Array[String], producer_id_filters : Array[Int64], duration_filter : Int64, transactional_id_pattern : String?, timeout_ms? : Int) -> AdminListTransactionsResult

    BrokerConnection::negotiate_api_versions

    async fn BrokerConnection::negotiate_api_versions(self : BrokerConnection, timeout_ms? : Int) -> Unit

    Run the ApiVersions handshake and store the broker's advertised ranges; later requests pick their version from them (api_version).

    BrokerConnection::note_throttle

    fn BrokerConnection::note_throttle(self : BrokerConnection, throttle_ms : Int) -> Unit

    Record the broker's latest throttle hint, keeping the furthest deadline.

    BrokerConnection::offset_commit

    async fn BrokerConnection::offset_commit(self : BrokerConnection, group_id : String, generation_id_or_member_epoch : Int, member_id : String, group_instance_id? : String?, topics~ : Array[CommitTopic], timeout_ms? : Int) -> Array[OffsetCommitPartitionResult]

    BrokerConnection::offset_delete

    async fn BrokerConnection::offset_delete(self : BrokerConnection, group_id : String, topics : Array[(String, Array[Int])], timeout_ms : Int) -> OffsetDeleteResult

    BrokerConnection::offset_fetch

    async fn BrokerConnection::offset_fetch(self : BrokerConnection, group_id : String, member_id? : String, member_epoch? : Int, topics~ : Array[FetchOffsetTopic], require_stable? : Bool, timeout_ms? : Int) -> Array[OffsetFetchGroupResult]

    BrokerConnection::offset_for_leader_epoch

    async fn BrokerConnection::offset_for_leader_epoch(self : BrokerConnection, topic : String, partitions : Array[(Int, Int, Int)], timeout_ms? : Int) -> Array[EpochEndOffset]

    BrokerConnection::produce

    async fn BrokerConnection::produce(self : BrokerConnection, topic : String, topic_id? : Uuid, transactional_id? : String?, partitions~ : Array[(Int, Bytes)], acks~ : Int, timeout_ms~ : Int) -> Array[ProducePartitionResult]

    Produce one batch per partition to a single topic. topic_id comes from metadata and is mandatory once the negotiated version is 13. The acks validation (1 or -1) lives in ProducerConfig.

    BrokerConnection::push_telemetry

    async fn BrokerConnection::push_telemetry(self : BrokerConnection, client_instance_id : Uuid, subscription_id : Int, metrics : Bytes, terminating? : Bool, compression_type? : Int, timeout_ms? : Int) -> Int

    BrokerConnection::request

    async fn BrokerConnection::request(self : BrokerConnection, api_key : Int, api_version : Int, body : Bytes, timeout_ms? : Int) ->
    Decoder

    Send one request and wait for its response. At most max_in_flight requests run concurrently; the rest queue on the semaphore. On timeout or any transport failure the connection is closed.

    BrokerConnection::request_raw

    async fn BrokerConnection::request_raw(self : BrokerConnection, api_key : Int, api_version : Int, body : Bytes, timeout_ms? : Int, flexible? : Bool) ->
    Decoder

    Like request, but for APIs whose chosen version is not flexible (request header v1, response header v0): SaslHandshake v1 today.

    BrokerConnection::send_only

    async fn BrokerConnection::send_only(self : BrokerConnection, api_key : Int, api_version : Int, body : Bytes) -> Unit

    Write a request frame without awaiting a response — Produce with acks=0, where the broker sends none. The correlation id still advances so later responses keep their numbering; no in-flight slot is consumed since nothing waits.

    BrokerConnection::share_acknowledge

    async fn BrokerConnection::share_acknowledge(self : BrokerConnection, group_id : String, member_id : String, session_epoch : Int, topics : Array[ShareFetchTopic], timeout_ms? : Int) -> ShareAcknowledgeResult

    BrokerConnection::share_fetch

    async fn BrokerConnection::share_fetch(self : BrokerConnection, group_id : String, member_id : String, session_epoch : Int, topics : Array[ShareFetchTopic], forgotten? : Array[ShareForgottenTopic], max_wait_ms~ : Int, timeout_ms? : Int) -> ShareFetchResult

    BrokerConnection::share_group_heartbeat

    async fn BrokerConnection::share_group_heartbeat(self : BrokerConnection, group_id : String, member_id : String, member_epoch : Int, rack_id? : String?, subscribed_topic_names? : Array[String]?, timeout_ms? : Int) -> ShareGroupHeartbeatResult

    BrokerConnection::sync_group

    async fn BrokerConnection::sync_group(self : BrokerConnection, group_id : String, generation_id : Int, member_id : String, group_instance_id? : String?, protocol_name? : String, assignments~ : Array[SyncGroupAssignment], timeout_ms? : Int) -> SyncGroupResult

    BrokerConnection::throttle_total_ms

    fn BrokerConnection::throttle_total_ms(self : BrokerConnection) -> Int64

    Cumulative throttle hints received on this connection.

    BrokerConnection::txn_offset_commit

    async fn BrokerConnection::txn_offset_commit(self : BrokerConnection, transactional_id : String, group_id : String, producer_id : Int64, producer_epoch : Int, topics : Array[(String, Array[TxnOffset])], timeout_ms? : Int) -> Array[TxnPartitionResult]

    BrokerConnection::unregister_broker

    async fn BrokerConnection::unregister_broker(self : BrokerConnection, broker_id : Int, timeout_ms? : Int) -> UnregisterBrokerResult

    BrokerConnection::update_features

    async fn BrokerConnection::update_features(self : BrokerConnection, updates : Array[FeatureUpdate], timeout_ms? : Int, validate_only? : Bool) -> AdminUpdateFeaturesResult

    BrokerInfo

    pub struct BrokerInfo {
    node_id : Int
    host : String
    port : Int
    }

    BrokerStream

    pub(all) enum BrokerStream {
    Plain(
    Tcp
    )
    Secure(
    Tls
    )
    }

    Byte stream to a broker: plaintext TCP, or TLS layered over TCP.

    BrokerStream::read_exactly

    async fn BrokerStream::read_exactly(self : BrokerStream, n : Int) -> Bytes

    BrokerStream::shutdown

    fn BrokerStream::shutdown(self : BrokerStream) -> Unit

    Release the stream. The TLS layer must be freed before the raw socket underneath it, per the @tls requirements.

    BrokerStream::write

    async fn BrokerStream::write(self : BrokerStream, data : Bytes) -> Unit

    BrokerVersions

    pub struct BrokerVersions {
    ranges : Map[Int, (Int, Int)]
    }

    The version ranges a broker advertised in its ApiVersions response.

    BrokerVersions::pick

    fn BrokerVersions::pick(self : BrokerVersions, api_key : Int, want? : Int?) -> Int raise

    Choose the request version for api_key: the highest version common to the driver's implemented range and this broker's advertised range, capped at want (the driver's ceiling when omitted). Raises when the broker does not advertise the API at all, or when no version overlaps — the telltale of a pre-4.0 broker.

    BrokerVersions::range

    fn BrokerVersions::range(self : BrokerVersions, api_key : Int) -> (Int, Int)?

    The broker's advertised range for one API, if it advertises the key.

    ClientQuotaAlteration

    pub(all) struct ClientQuotaAlteration {
    entity : Array[QuotaEntity]
    ops : Array[ClientQuotaOp]
    } derive(
    Debug
    )

    Alter the quota config of one entity.

    ClientQuotaFilter

    pub(all) struct ClientQuotaFilter {
    components : Array[ClientQuotaFilterComponent]
    strict : Bool
    } derive(
    Debug
    )

    Which quota entities DescribeClientQuotas returns: every component must match (AND); strict excludes entities that carry entity types beyond the filtered ones.

    ClientQuotaFilterComponent

    pub(all) struct ClientQuotaFilterComponent {
    entity_type : String
    match_type : Int
    matches : String?
    } derive(
    Debug
    )

    One filter component: which entity type to match and how (exact name, defaulted name, or any specified name; ANY matches the null default entity too).

    ClientQuotaOp

    pub(all) struct ClientQuotaOp {
    key : String
    value : Double
    remove : Bool
    } derive(
    Debug
    )

    One config key to set or remove on an entity.

    ClientQuotaValue

    pub(all) struct ClientQuotaValue {
    key : String
    value : Double
    } derive(
    Debug
    )

    One quota config value of a described entity (producer_byte_rate, consumer_byte_rate, request_percentage, ...).

    ClientQuotasEntry

    pub struct ClientQuotasEntry {
    entity : Array[QuotaEntity]
    values : Array[ClientQuotaValue]
    } derive(
    Debug
    )

    The quotas configured on one entity.

    ClusterClient

    pub struct ClusterClient {
    bootstrap : BootstrapServers
    client_id : String
    request_timeout_ms : Int
    metadata_max_age_ms : Int
    max_in_flight : Int
    sasl : SaslConfig?
    use_tls : Bool
    tls_options : TlsClientOptions?
    lock :
    Mutex

    brokers : Map[Int, BrokerInfo]
    topics : Map[String, TopicMetadata]
    topic_ids : Map[Uuid, String]
    controller_id : Int
    refreshed_ms : Int64
    conns : Map[Int, BrokerConnection]
    // private fields
    }

    ClusterClient::broker_ids

    fn ClusterClient::broker_ids(self : ClusterClient) -> Array[Int]

    Node ids of every broker in the cached metadata snapshot, sorted so a fan-out visits them in a stable order. For the admin calls a broker answers only from the state it holds itself — ListGroups and ListTransactions — which the client must send to all brokers and merge. Empty before the first refresh_metadata.

    ClusterClient::close

    fn ClusterClient::close(self : ClusterClient) -> Unit

    Tear down the control connection and the whole pool.

    ClusterClient::connect

    async fn ClusterClient::connect(bootstrap_addresses : Array[HostPort], client_id? : String, request_timeout_ms? : Int, metadata_max_age_ms? : Int, max_in_flight? : Int, sasl? : SaslConfig?, use_tls? : Bool, tls? : TlsClientOptions?) -> ClusterClient

    Dial the bootstrap set (rotating, SASL, TLS, ApiVersions negotiation) and return the client; metadata starts empty and stale, so the first refresh_metadata is on the caller.

    ClusterClient::connection

    async fn ClusterClient::connection(self : ClusterClient, node_id : Int) -> BrokerConnection

    A pooled connection to the broker behind node_id, dialed (with SASL and ApiVersions negotiation) on first use. Dial and authentication errors propagate; the pool stays consistent.

    ClusterClient::control_conn

    fn ClusterClient::control_conn(self : ClusterClient) -> BrokerConnection

    The any-broker control connection, for direct cluster-level requests.

    ClusterClient::controller

    fn ClusterClient::controller(self : ClusterClient) -> Int

    The cached controller node id (-1 before the first metadata refresh) for controller-routed admin ops.

    ClusterClient::coordinator

    async fn ClusterClient::coordinator(self : ClusterClient, keys : Array[String], coordinator_type : CoordinatorType) -> Map[String, CoordinatorInfo]

    Batched coordinator lookup through the control connection, keyed by the requested key. Per-key broker errors come back inside the entries (error_code); transport failures propagate.

    ClusterClient::invalidate_metadata

    fn ClusterClient::invalidate_metadata(self : ClusterClient) -> Unit

    Force the next refresh_if_stale to treat the cache as cold (the error-triggered half of refresh scheduling; a retry path may simply call refresh_metadata instead).

    ClusterClient::reconnect

    async fn ClusterClient::reconnect(self : ClusterClient) -> Unit

    Re-dial the bootstrap set after a transport failure: the control connection and every pooled connection are dropped; metadata stays stale until the caller refreshes. Callers keep their per-client state (positions, accumulator) across the swap.

    ClusterClient::refresh_if_stale

    async fn ClusterClient::refresh_if_stale(self : ClusterClient) -> Unit

    Opportunistic refresh when the cached snapshot aged out. Refresh failures are swallowed — staleness surfaces on use, where callers run their own recovery; Java's background refresher lands with the sender task (D6).

    ClusterClient::refresh_metadata

    async fn ClusterClient::refresh_metadata(self : ClusterClient, topics : Array[String]?) -> Unit

    Fetch metadata (None asks for all topics) and refresh the broker map, topic map, topic-id map, and the refresh clock. Errors leave the old snapshot in place.

    ClusterClient::supports_api

    fn ClusterClient::supports_api(self : ClusterClient, api_key : Int) -> Bool

    Whether the broker advertises the given API key at all (protocol capability probe for the group-protocol fallback).

    ClusterClient::topic

    fn ClusterClient::topic(self : ClusterClient, name : String) -> TopicMetadata?

    The cached metadata snapshot for one topic, if known.

    ClusterClient::topic_name

    fn ClusterClient::topic_name(self : ClusterClient, id : Uuid) -> String?

    The topic name behind a topic id (KIP-516), when in the cache.

    ClusterClient::topics_snapshot

    fn ClusterClient::topics_snapshot(self : ClusterClient) -> Array[String]

    Names of every topic in the cached metadata snapshot (subscription expansion for regex consumers).

    ClusterClient::total_throttle_ms

    fn ClusterClient::total_throttle_ms(self : ClusterClient) -> Int64

    Sum of the throttle hints received across the control connection and every pooled connection.

    ClusterClient::wait_for_topic

    async fn ClusterClient::wait_for_topic(self : ClusterClient, topic : String, timeout_ms? : Int) -> TopicMetadata

    Fetch metadata for one topic and wait until it has at least one partition with a leader. Topic auto-creation is asynchronous in KRaft: the broker answers the first metadata request for a brand-new topic with UNKNOWN_TOPIC_OR_PARTITION and materializes it (then elects leaders) moments later. Retry on those retriable per-topic errors — Java's waitOnMetadata — until the topic is ready or timeout_ms lapses.

    CommitTopic

    pub(all) struct CommitTopic {
    name : String
    topic_id : Uuid
    partitions : Array[(Int, Int64, Int)]
    } derive(
    Debug
    )

    One topic's partitions to commit: (name, topic id, entries) where an entry is (partition, offset, committed leader epoch). The encoder picks name or id addressing from the negotiated version.

    CommittedOffset

    pub(all) struct CommittedOffset {
    topic : String
    partition : Int
    offset : Int64
    leader_epoch : Int
    error_code : Int
    } derive(
    Debug
    )

    One fetched committed offset.

    CommonConfig

    pub struct CommonConfig {
    bootstrap_servers : Array[String]
    client_id : String
    request_timeout_ms : Int
    connection_max_idle_ms : Int
    metadata_max_age_ms : Int
    retries : Int
    retry_backoff_ms : Int
    retry_backoff_max_ms : Int
    security_protocol : SecurityProtocol
    sasl : SaslConfig?
    tls : TlsClientOptions?
    } derive(
    Debug
    )

    Settings shared by every client surface.

    CommonConfig::bootstrap_addresses

    fn CommonConfig::bootstrap_addresses(self : CommonConfig) -> Array[HostPort] raise ProtocolError

    Parse every bootstrap entry; raises on the first malformed one.

    CommonConfig::new

    fn CommonConfig::new(bootstrap_servers : Array[String], request_timeout_ms? : Int, security_protocol? : SecurityProtocol, sasl? : SaslConfig?, tls? : TlsClientOptions?, metadata_max_age_ms? : Int) -> CommonConfig raise

    Defaults mirror the Java client where sensible: 30s request timeout, 9-minute idle connection limit. Retries are bounded at 10 for now — the Java default is effectively unbounded but is gated by delivery.timeout.ms, which the batching producer (Phase 3) introduces.

    CommonConfig::validate

    fn CommonConfig::validate(self : CommonConfig) -> Unit raise ProtocolError

    Reject values that would make a client misbehave; called by new.

    ConfigResourceKey

    pub(all) struct ConfigResourceKey {
    resource_type : Int
    resource_name : String
    config_keys : Array[String]?
    } derive(
    Debug
    )

    One config resource to describe: type + name, with an optional key filter (None lists every key).

    ConfigResourceListing

    pub(all) struct ConfigResourceListing {
    resource_name : String
    resource_type : Int
    } derive(
    Debug
    )

    One config resource the broker lists: name plus type (v1+; 0 below).

    Consumer

    pub struct Consumer {
    topic : String
    start_from : StartFrom
    request_timeout_ms : Int
    retries : Int
    retry_backoff_ms : Int
    retry_backoff_max_ms : Int
    group :
    TaskGroup
    [Unit]
    enable_auto_commit : Bool
    auto_commit_interval_ms : Int
    auto_offset_reset : AutoOffsetReset
    max_poll_records : Int
    max_partition_fetch_bytes : Int
    enable_read_committed : Bool
    heartbeat_interval_ms : Int
    session_timeout_ms : Int
    last_poll_ms : Int64
    max_poll_interval_ms : Int
    group_protocol : GroupProtocol
    topic_id : Uuid
    fetch_sessions : Map[Int, FetchSession]
    partitions : Array[PartitionState]
    closed : Bool
    // private fields
    }

    Consumer::assign

    async fn Consumer::assign(self : Consumer, partitions : Array[(String, Int)]) -> Unit

    Manually assign topic partitions (the subscribe-less path): the consumer fetches exactly these partitions of its topic without group coordination. Positions start from the committed offsets when a group_id is configured, else from the auto-offset-reset sentinel. Mutually exclusive with subscribe().

    Consumer::assignment

    fn Consumer::assignment(self : Consumer) -> Array[(String, Int)]

    The topic partitions currently assigned to this member.

    Consumer::close

    fn Consumer::close(self : Consumer) -> Unit

    Stop the consumer: the autocommit loop (if any) commits the current positions once more, then tears the cluster connections down before the group joins it.

    Consumer::commit

    async fn Consumer::commit(self : Consumer, offsets? : Map[Int, Int64]) -> Unit

    Commit offsets to the group coordinator: offsets explicitly, or every partition's current position when omitted. Retriable coordinator/rebalance errors retry with backoff; success refreshes the committed-offset cache.

    Consumer::commit_async

    fn Consumer::commit_async(self : Consumer, offsets? : Map[Int, Int64], on_complete? : (String?) -> Unit) -> Unit raise

    Commit in the background: the commit runs in the consumer's task group and on_complete receives None on success or the error message. Nothing is awaited.

    Consumer::committed

    async fn Consumer::committed(self : Consumer, partitions? : Array[Int]?) -> Map[Int, Int64]

    Fetch the last committed offsets for the topic's partitions (or the given ones) from the coordinator, refresh the cache, and return the map. Partitions without a commit carry -1.

    Consumer::committed_cached

    fn Consumer::committed_cached(self : Consumer, partition : Int) -> Int64?

    The cached committed offset for one partition, if known locally. Call committed() to refresh from the coordinator.

    Consumer::connect

    async fn Consumer::connect(group~ :
    TaskGroup
    [Unit], host~ : String, port~ : Int, topic~ : String, start_from? : StartFrom) -> Consumer

    Connect to a bootstrap broker, negotiate API versions, resolve the topic's partitions and their leaders, and initialize fetch offsets. The autocommit loop (when configured) joins group.

    Consumer::connect_with_config

    async fn Consumer::connect_with_config(group~ :
    TaskGroup
    [Unit], config : ConsumerConfig) -> Consumer

    Connect using explicit configuration, which is validated first. The meta connection lands on the first bootstrap server that accepts.

    Consumer::group_metadata

    fn Consumer::group_metadata(self : Consumer) -> GroupMetadata?

    The group identity this consumer participates in, if configured.

    Consumer::member_identity

    fn Consumer::member_identity(self : Consumer) -> String

    This member's id (client-generated, stable for the consumer's lifetime); empty while not subscribed.

    Consumer::membership_error

    fn Consumer::membership_error(self : Consumer) -> String?

    The last fatal membership error, if the loop stopped on one.

    Consumer::pause

    fn Consumer::pause(self : Consumer, partitions? : Array[Int]) -> Unit

    Pause fetching from the given partitions (default: all). Paused partitions keep their positions; poll skips them until resume.

    Consumer::paused

    fn Consumer::paused(self : Consumer) -> Array[Int]

    The partitions currently paused.

    Consumer::poll

    async fn Consumer::poll(self : Consumer, max_wait_ms? : Int, max_bytes? : Int) -> Array[Record]

    Poll the assigned partitions once. Returns up to max_poll_records decoded records (possibly empty; the broker long-polls up to max_wait_ms per fetch). Paused partitions are skipped.

    Fetches run concurrently per leader through incremental fetch sessions: the first request carries every partition, later ones only partitions whose position changed since the broker last heard (session eviction and INVALID_FETCH_SESSION_EPOCH restart with a full request). Recovery: transport failures refresh metadata; OFFSET_OUT_OF_RANGE follows the auto-reset policy; UNKNOWN/FENCED_LEADER_EPOCH validate the position against the leader's epoch end offset (KIP-320) and rewind on truncation. READ_COMMITTED consumers filter aborted transactions; read positions always advance past whole batches, so markers and aborted ranges are never re-fetched.

    Consumer::position

    fn Consumer::position(self : Consumer, partition : Int) -> Int64?

    The current read position of one partition, if it is part of the consumer's metadata view.

    Consumer::seek

    fn Consumer::seek(self : Consumer, partition : Int, offset : Int64) -> Unit raise

    Move the read position of one partition to offset (no validation against the log; the next poll surfaces OFFSET_OUT_OF_RANGE if it is outside).

    Consumer::seek_by_timestamp

    async fn Consumer::seek_by_timestamp(self : Consumer, partition : Int, timestamp : Int64) -> Unit

    Move one partition's read position to the offset of the first record whose timestamp is >= timestamp (ListOffsets by timestamp).

    Consumer::seek_to_beginning

    async fn Consumer::seek_to_beginning(self : Consumer, partitions? : Array[Int]?) -> Unit

    Resolve the given partitions (default: all) to the log start offset.

    Consumer::seek_to_end

    async fn Consumer::seek_to_end(self : Consumer, partitions? : Array[Int]?) -> Unit

    Resolve the given partitions (default: all) to the log end offset.

    Consumer::subscribe

    fn Consumer::subscribe(self : Consumer, topics : Array[String], listener? : RebalanceListener?) -> Unit raise

    Subscribe to explicit topics and start (or join) the group membership loop in the consumer's task group. Requires a group_id.

    Consumer::subscribe_classic

    fn Consumer::subscribe_classic(self : Consumer, topics : Array[String], assignors? : Array[Assignor], listener? : RebalanceListener?) -> Unit raise

    Subscribe with the classic protocol: JoinGroup/SyncGroup under the given assignment strategies (most-preferred first; the group runs on the one the coordinator settles on).

    Consumer::subscribe_regex

    async fn Consumer::subscribe_regex(self : Consumer, pattern : String, listener? : RebalanceListener?) -> Unit

    Subscribe with a topic pattern: the pattern rides the heartbeat (v1) and the client expands it against metadata to drive fetches.

    Consumer::unassign

    fn Consumer::unassign(self : Consumer) -> Unit

    Drop the manual assignment; poll stops fetching until a new one is set.

    Consumer::unpause

    fn Consumer::unpause(self : Consumer, partitions? : Array[Int]) -> Unit

    Resume fetching from the given partitions (default: all).

    Consumer::unsubscribe

    async fn Consumer::unsubscribe(self : Consumer) -> Unit

    Leave the group gracefully: a final heartbeat with epoch -1, revoke the assignment, and stop the loop.

    ConsumerConfig

    pub struct ConsumerConfig {
    common : CommonConfig
    topic : String
    start_from : StartFrom
    group_id : String?
    enable_auto_commit : Bool
    auto_commit_interval_ms : Int
    auto_offset_reset : AutoOffsetReset
    max_poll_records : Int
    max_partition_fetch_bytes : Int
    enable_read_committed : Bool
    group_instance_id : String?
    heartbeat_interval_ms : Int
    session_timeout_ms : Int
    max_poll_interval_ms : Int
    group_protocol : GroupProtocol
    } derive(
    Debug
    )

    ConsumerConfig::new

    fn ConsumerConfig::new(bootstrap_servers : Array[String], topic : String, start_from? : StartFrom, request_timeout_ms? : Int, security_protocol? : SecurityProtocol, sasl? : SaslConfig?, tls? : TlsClientOptions?, metadata_max_age_ms? : Int, group_id? : String?, enable_auto_commit? : Bool, auto_commit_interval_ms? : Int, auto_offset_reset? : AutoOffsetReset?, max_poll_records? : Int, max_partition_fetch_bytes? : Int, enable_read_committed? : Bool, group_instance_id? : String?, heartbeat_interval_ms? : Int, session_timeout_ms? : Int, max_poll_interval_ms? : Int, group_protocol? : GroupProtocol) -> ConsumerConfig raise

    ConsumerGroupHeartbeatResult

    pub struct ConsumerGroupHeartbeatResult {
    error_code : Int
    error_message : String?
    member_id : String
    member_epoch : Int
    heartbeat_interval_ms : Int
    assignment : Array[HeartbeatTopicPartitions]
    } derive(
    Debug
    )

    One member heartbeat outcome: identity/epoch reconciliation, the server's heartbeat interval, and the (possibly empty) assignment.

    CoordinatorInfo

    pub struct CoordinatorInfo {
    key : String
    node_id : Int
    host : String
    port : Int
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    One coordinator lookup result; error_code names per-key failures (COORDINATOR_NOT_AVAILABLE, GROUP_AUTHORIZATION_FAILED, ...).

    CoordinatorType

    pub(all) enum CoordinatorType {
    Group
    Transaction
    Share
    } derive(Eq,
    Debug
    )

    What kind of coordinator to look up. Group and Transaction cover the consumer-group and transaction flows; Share arrives with KIP-932.

    CreatableTopic

    pub(all) struct CreatableTopic {
    name : String
    num_partitions : Int
    replication_factor : Int
    assignments : Array[(Int, Array[Int])]
    configs : Array[(String, String?)]
    } derive(
    Debug
    )

    One topic to create: either num_partitions/replication_factor (use -1 for broker defaults) or explicit replica assignments, plus config overrides.

    CreateAclsResult

    pub struct CreateAclsResult {
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    One ACL creation result.

    CreatePartitionsResult

    pub struct CreatePartitionsResult {
    name : String
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    CreatePartitionsSpec

    pub(all) struct CreatePartitionsSpec {
    name : String
    count : Int
    assignments : Array[Array[Int]]?
    } derive(
    Debug
    )

    One topic to grow: the new partition count, optionally with replica assignments for the new partitions (new-assignments-first order).

    CreateTopicsResult

    pub struct CreateTopicsResult {
    name : String
    topic_id : Uuid
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    Deadline

    pub struct Deadline {
    at_ms : Int64
    } derive(
    Debug
    )

    A point in time measured against the @async wall clock.

    Deadline::after_ms

    fn Deadline::after_ms(ms : Int64) -> Deadline

    Deadline::expired

    fn Deadline::expired(self : Deadline) -> Bool

    Deadline::remaining_ms

    fn Deadline::remaining_ms(self : Deadline) -> Int64

    Milliseconds until expiry; negative once past.

    DecodedBatch

    pub(all) struct DecodedBatch {
    records : Array[Record]
    last_offset : Int64
    producer_id : Int64
    producer_epoch : Int
    base_sequence : Int
    is_control : Bool
    is_transactional : Bool
    truncated : Bool
    } derive(
    Debug
    )

    One decoded record batch with the metadata read_committed filtering and the idempotence machinery need: identity, flags, and whether the byte stream ended mid-batch (max_bytes split).

    DeleteAclsFilterResult

    pub struct DeleteAclsFilterResult {
    error_code : Int
    error_message : String?
    matching_acls : Array[DeletedAcl]
    } derive(
    Debug
    )

    DeleteRecordsResult

    pub struct DeleteRecordsResult {
    topic : String
    partition : Int
    low_watermark : Int64
    error_code : Int
    } derive(
    Debug
    )

    One deleted-records result: the new low watermark, or the error.

    DeleteTopicsResult

    pub struct DeleteTopicsResult {
    name : String?
    topic_id : Uuid
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    DeletedAcl

    pub struct DeletedAcl {
    error_code : Int
    error_message : String?
    binding : AclBinding
    } derive(
    Debug
    )

    One ACL a delete filter matched, with its own deletion error.

    DescribeAclsResult

    pub struct DescribeAclsResult {
    error_code : Int
    error_message : String?
    resources : Array[DescribedAclResource]
    } derive(
    Debug
    )

    DescribeClientQuotasResult

    pub struct DescribeClientQuotasResult {
    error_code : Int
    error_message : String?
    entries : Array[ClientQuotasEntry]
    } derive(
    Debug
    )

    DescribeTopicPartitions

    pub struct DescribeTopicPartitions {
    topics : Array[TopicMetadata]
    next_cursor : TopicPartitionCursor?
    }

    One page of DescribeTopicPartitions results. next_cursor is set when the broker truncated the response at the partition limit.

    DescribeUserScramResult

    pub struct DescribeUserScramResult {
    error_code : Int
    error_message : String?
    results : Array[DescribedScramCredentials]
    } derive(
    Debug
    )

    DescribedAclResource

    pub struct DescribedAclResource {
    resource_type : Int
    resource_name : String
    pattern_type : Int
    acls : Array[AclDescription]
    } derive(
    Debug
    )

    DescribedScramCredentials

    pub struct DescribedScramCredentials {
    user : String
    error_code : Int
    error_message : String?
    credential_infos : Array[ScramCredentialInfo]
    } derive(
    Debug
    )

    One user's SCRAM credentials as stored on the broker.

    ElectLeadersPartitionResult

    pub struct ElectLeadersPartitionResult {
    partition : Int
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    ElectLeadersTopicResult

    pub struct ElectLeadersTopicResult {
    topic : String
    partitions : Array[ElectLeadersPartitionResult]
    } derive(
    Debug
    )

    EndTxnResult

    pub struct EndTxnResult {
    error_code : Int
    producer_id : Int64
    producer_epoch : Int
    } derive(
    Debug
    )

    EndTxn v5 outcome: the broker error code plus the (possibly bumped) producer identity the coordinator returns (v5, KIP-890 part 2).

    EpochEndOffset

    pub struct EpochEndOffset {
    partition : Int
    error_code : Int
    leader_epoch : Int
    end_offset : Int64
    } derive(
    Debug
    )

    One partition's epoch end offset.

    FeatureUpdate

    pub(all) struct FeatureUpdate {
    feature : String
    max_version_level : Int
    upgrade_type : Int
    } derive(
    Debug
    )

    One finalized feature level update.

    FetchOffsetTopic

    pub(all) struct FetchOffsetTopic {
    name : String
    topic_id : Uuid
    partitions : Array[Int]
    } derive(
    Debug
    )

    One topic's wanted partitions for an OffsetFetch: (name, topic id, partition indexes). The encoder picks name or id addressing from the negotiated version.

    FetchPartitionReq

    pub(all) struct FetchPartitionReq {
    index : Int
    leader_epoch : Int
    fetch_offset : Int64
    max_bytes : Int
    } derive(
    Debug
    )

    One partition to fetch, as the request carries it.

    FetchPartitionResult

    pub struct FetchPartitionResult {
    partition : Int
    error_code : Int
    high_watermark : Int64
    last_stable_offset : Int64
    log_start_offset : Int64
    records : Array[Record]
    batches : Array[DecodedBatch]
    aborted_transactions : Array[AbortedTx]
    records_complete : Bool
    }

    FetchResult

    pub struct FetchResult {
    top_error_code : Int
    session_id : Int
    topics : Array[FetchTopicResult]
    }

    FetchSession

    pub struct FetchSession {
    session_id : Int
    next_epoch : Int
    sent : Map[Int, (Int64, Int)]
    } derive(
    Debug
    )

    Client-side state of one fetch session (one per leader connection). sent mirrors what the broker last heard per partition, so the next incremental request can carry only the changed ones.

    FetchSession::established

    fn FetchSession::established(self : FetchSession) -> Bool

    True while no session is established: requests go out as full fetches.

    FetchSession::handle_response

    fn FetchSession::handle_response(self : FetchSession, response_session_id : Int, top_error_code : Int) -> Unit

    Fold a response into the session state: adopt the broker's session id, or restart with a full request after eviction (top-level error 70/71) or when the broker closes the session (session id 0 in reply).

    FetchSession::invalidate

    fn FetchSession::invalidate(self : FetchSession) -> Unit

    Drop the session unconditionally (connection rebuilds, leadership changes): the next request is a full fetch.

    FetchSession::new

    FetchSession::prepare

    fn FetchSession::prepare(self : FetchSession, topic_name : String, topic_id : Uuid, wanted : Map[Int, (Int64, Int)], max_bytes : Int) -> FetchSessionReq

    Build the next request against the desired partition parameters (partition index -> (fetch offset, leader epoch)). Single-topic shape: topic_name/topic_id identify the forgotten-partitions entries on the wire (v12 needs the name, v13+ the id).

    FetchSessionReq

    pub(all) struct FetchSessionReq {
    session_id : Int
    session_epoch : Int
    partitions : Array[FetchPartitionReq]
    forgotten : Array[FetchTopicForgotten]
    } derive(
    Debug
    )

    The session portion of a fetch request: what to put in the session_id/session_epoch fields and which partitions to (re)send.

    FetchTopicForgotten

    pub(all) struct FetchTopicForgotten {
    name : String
    topic_id : Uuid
    partitions : Array[Int]
    } derive(
    Debug
    )

    One topic's partitions to remove from an established session.

    FetchTopicReq

    pub(all) struct FetchTopicReq {
    name : String
    topic_id : Uuid
    partitions : Array[FetchPartitionReq]
    } derive(
    Debug
    )

    One topic to fetch: both identifiers so any implemented version can encode (v12 uses the name, v13+ the id).

    FetchTopicResult

    pub struct FetchTopicResult {
    name : String
    topic_id : Uuid
    partitions : Array[FetchPartitionResult]
    }

    GroupMetadata

    pub(all) struct GroupMetadata {
    group_id : String
    member_id : String
    generation_id : Int
    } derive(
    Debug
    )

    The consumer group's identity as this member sees it: None for a group-less consumer; an empty member id and generation -1 before the first join.

    GroupProtocol

    pub(all) enum GroupProtocol {
    ConsumerProtocol
    ClassicProtocol
    PreferConsumer
    PreferClassic
    } derive(Eq,
    Debug
    )

    Which consumer-group protocol subscribe() runs (Java's group.protocol). Consumer is the KIP-848 path; Classic the JoinGroup/SyncGroup compat path; the fallback orders try the preferred protocol first and degrade to the other when the broker does not advertise it.

    HeartbeatTopicPartitions

    pub(all) struct HeartbeatTopicPartitions {
    topic_id : Uuid
    partitions : Array[Int]
    } derive(
    Debug
    )

    One topic's partitions in a heartbeat assignment (topic-id addressed).

    HostPort

    pub(all) struct HostPort {
    host : String
    port : Int
    } derive(Compare, Eq, Hash,
    Debug
    )

    One "host:port" (or "[ipv6]:port") entry of the bootstrap list.

    HostPort::parse

    fn HostPort::parse(entry : String) -> HostPort raise ProtocolError

    Parse a single bootstrap entry. The port defaults to 9092 when omitted; bare IPv6 addresses must be bracketed.

    InitProducerIdResult

    pub struct InitProducerIdResult {
    producer_id : Int64
    producer_epoch : Int
    error_code : Int
    } derive(
    Debug
    )

    JoinGroupMember

    pub struct JoinGroupMember {
    member_id : String
    group_instance_id : String?
    metadata : Bytes
    } derive(
    Debug
    )

    One member's entry in a JoinGroup response.

    JoinGroupProtocol

    pub(all) struct JoinGroupProtocol {
    name : String
    metadata : Bytes
    } derive(
    Debug
    )

    One protocol entry of a JoinGroup request: the assignor name and its serialized ConsumerProtocolSubscription.

    JoinGroupResult

    pub struct JoinGroupResult {
    error_code : Int
    generation_id : Int
    protocol_name : String
    leader_id : String
    member_id : String
    members : Array[JoinGroupMember]
    } derive(
    Debug
    )

    LeaveGroupMemberResult

    pub struct LeaveGroupMemberResult {
    member_id : String
    error_code : Int
    } derive(
    Debug
    )

    ListConfigResourcesResult

    pub struct ListConfigResourcesResult {
    error_code : Int
    resources : Array[ConfigResourceListing]
    } derive(
    Debug
    )

    LogDirPartition

    pub(all) struct LogDirPartition {
    partition_index : Int
    partition_size : Int64
    offset_lag : Int64
    is_future : Bool
    } derive(
    Debug
    )

    One partition of a log-dir result.

    LogDirResult

    pub struct LogDirResult {
    error_code : Int
    log_dir : String
    topics : Array[LogDirTopic]
    total_bytes : Int64
    usable_bytes : Int64
    is_cordoned : Bool
    } derive(
    Debug
    )

    LogDirTopic

    pub(all) struct LogDirTopic {
    name : String
    partitions : Array[LogDirPartition]
    } derive(
    Debug
    )

    Metadata

    pub struct Metadata {
    brokers : Map[Int, BrokerInfo]
    controller_id : Int
    topics : Array[TopicMetadata]
    }

    OffsetCommitPartitionResult

    pub struct OffsetCommitPartitionResult {
    partition : Int
    error_code : Int
    } derive(
    Debug
    )

    One partition's commit outcome: (partition index, error code).

    OffsetDeletePartitionResult

    pub struct OffsetDeletePartitionResult {
    topic : String
    partition : Int
    error_code : Int
    } derive(
    Debug
    )

    OffsetDeleteResult

    pub struct OffsetDeleteResult {
    error_code : Int
    partitions : Array[OffsetDeletePartitionResult]
    } derive(
    Debug
    )

    OffsetFetchGroupResult

    pub struct OffsetFetchGroupResult {
    group_id : String
    error_code : Int
    partitions : Array[CommittedOffset]
    } derive(
    Debug
    )

    One group's OffsetFetch result.

    OngoingPartitionReassignment

    pub struct OngoingPartitionReassignment {
    partition_index : Int
    replicas : Array[Int]
    adding_replicas : Array[Int]
    removing_replicas : Array[Int]
    } derive(
    Debug
    )

    PartitionInfo

    pub struct PartitionInfo {
    index : Int
    leader : Int
    leader_epoch : Int
    } derive(
    Debug
    )

    PartitionState

    type PartitionState

    Partitioner

    pub(all) enum Partitioner {
    Murmur2
    Murmur2RoundRobin
    RoundRobin
    } derive(Eq,
    Debug
    )

    Partition assignment strategy, selected in ProducerConfig.

    ProducePartitionResult

    pub struct ProducePartitionResult {
    partition : Int
    error_code : Int
    base_offset : Int64
    log_append_time : Int64
    log_start_offset : Int64
    record_errors : Array[ProduceRecordError]
    error_message : String?
    }

    ProduceRecordError

    pub(all) struct ProduceRecordError {
    batch_index : Int
    message : String?
    } derive(
    Debug
    )

    Producer

    pub struct Producer {
    topic : String
    acks : Int
    timeout_ms : Int
    retries : Int
    retry_backoff_ms : Int
    retry_backoff_max_ms : Int
    delivery_timeout_ms : Int
    group :
    TaskGroup
    [Unit]
    enable_idempotence : Bool
    producer_id : Int64
    producer_epoch : Int
    topic_id : Uuid
    partitions : Array[PartitionInfo]
    closed : Bool
    // private fields
    }

    Producer::abort_transaction

    async fn Producer::abort_transaction(self : Producer) -> Unit

    Abort the ongoing transaction: drain what is queued, then ask the coordinator to abort, discarding the records appended since begin.

    Producer::begin_transaction

    async fn Producer::begin_transaction(self : Producer) -> Unit

    Start a transaction: records appended after this point are stamped into batches the sender routes through AddPartitionsToTxn, and commit_transaction makes them visible atomically.

    Producer::close

    fn Producer::close(self : Producer) -> Unit

    Stop the producer: the sender task force-closes every open batch, drains what is queued (honoring retries and delivery_timeout_ms), resolves every pending send, and tears the cluster connections down on exit. Sends after close raise.

    Producer::commit_transaction

    async fn Producer::commit_transaction(self : Producer) -> Unit

    Commit the ongoing transaction: wait for every appended record to reach the log, then ask the coordinator to commit. Raises when any record failed since begin (abort instead) or the coordinator rejects the commit; a successful EndTxn v5 adopts the coordinator-bumped epoch (KIP-890 part 2) and continues the sequence numbers.

    Producer::connect

    async fn Producer::connect(group~ :
    TaskGroup
    [Unit], host~ : String, port~ : Int, topic~ : String, acks? : Int, timeout_ms? : Int) -> Producer

    Connect to a bootstrap broker, negotiate API versions, resolve the topic's partitions and their leaders, and start the sender drain loop in group. acks is 0 (fire-and-forget), 1 (leader) or -1 (all in-sync replicas).

    Producer::connect_with_config

    async fn Producer::connect_with_config(group~ :
    TaskGroup
    [Unit], config : ProducerConfig) -> Producer

    Connect using explicit configuration, which is validated first. The cluster client lands on the first bootstrap server that accepts, and the sender task drains the accumulator until close.

    Producer::metrics

    async fn Producer::metrics(self : Producer) -> ProducerMetrics

    Read the current counters.

    Producer::send

    async fn Producer::send(self : Producer, key? : Bytes, value? : Bytes, timestamp? : Int64, partition? : Int, headers? : Array[(Bytes, Bytes)]) -> Int64

    Send one record and block until its offset is known.

    Producer::send_all

    async fn Producer::send_all(self : Producer, records : Array[SendRecord]) -> Array[SendHandle]

    Append a batch of records in one call and return their handles (in input order); each routes independently — by key, partitioner, or its partition override.

    Producer::send_handle

    async fn Producer::send_handle(self : Producer, key? : Bytes, value? : Bytes, timestamp? : Int64, partition? : Int, headers? : Array[(Bytes, Bytes)]) -> SendHandle

    Append one record without waiting for its result; the returned handle awaits, cancels, or attaches a callback.

    Producer::send_offsets_to_transaction

    async fn Producer::send_offsets_to_transaction(self : Producer, offsets : Array[(String, Array[TxnOffset])], group_id : String) -> Unit

    Commit offsets collected by a consumer to group_id inside the ongoing transaction: AddOffsetsToTxn registers the group with the transaction coordinator, then TxnOffsetCommit lands the offsets at the group coordinator. They become visible with the transaction's commit, not before.

    ProducerConfig

    pub struct ProducerConfig {
    common : CommonConfig
    topic : String
    acks : Int
    partitioner : Partitioner
    batch_size : Int
    linger_ms : Int
    buffer_memory : Int
    max_in_flight : Int
    delivery_timeout_ms : Int
    enable_idempotence : Bool
    transactional_id : String?
    transaction_timeout_ms : Int
    } derive(
    Debug
    )

    ProducerConfig::new

    fn ProducerConfig::new(bootstrap_servers : Array[String], topic : String, acks? : Int, request_timeout_ms? : Int, security_protocol? : SecurityProtocol, sasl? : SaslConfig?, tls? : TlsClientOptions?, partitioner? : Partitioner, batch_size? : Int, linger_ms? : Int, buffer_memory? : Int, metadata_max_age_ms? : Int, max_in_flight? : Int, delivery_timeout_ms? : Int, enable_idempotence? : Bool?, transactional_id? : String?, transaction_timeout_ms? : Int) -> ProducerConfig raise

    acks is 0 (fire-and-forget; the sender writes Produce requests without reading responses and send returns -1), 1 (leader acknowledgement) or -1 (all in-sync replicas). Defaults mirror the Java client: 16 KiB batches, no lingering, a 32 MiB buffer pool, 5 in-flight requests per broker, a 2-minute delivery timeout.

    ProducerMetrics

    pub struct ProducerMetrics {
    records_queued : Int
    bytes_queued : Int
    batches_in_flight : Int
    records_sent : Int
    records_failed : Int
    batches_sent : Int
    batches_failed : Int
    throttle_time_ms : Int64
    } derive(
    Debug
    )

    Snapshot of the producer's counters at read time.

    QuorumNode

    pub struct QuorumNode {
    node_id : Int
    listeners : Array[(String, String, Int)]
    } derive(
    Debug
    )

    QuorumPartitionState

    pub struct QuorumPartitionState {
    partition_index : Int
    error_code : Int
    error_message : String?
    leader_id : Int
    leader_epoch : Int
    high_watermark : Int64
    current_voters : Array[QuorumReplicaState]
    observers : Array[QuorumReplicaState]
    } derive(
    Debug
    )

    QuorumReplicaState

    pub(all) struct QuorumReplicaState {
    replica_id : Int
    replica_directory_id : Uuid
    log_end_offset : Int64
    last_fetch_timestamp : Int64
    last_caught_up_timestamp : Int64
    } derive(
    Debug
    )

    One quorum voter's / observer's progress.

    QuorumTopicState

    pub struct QuorumTopicState {
    topic_name : String
    partitions : Array[QuorumPartitionState]
    } derive(
    Debug
    )

    QuotaEntity

    pub(all) struct QuotaEntity {
    entity_type : String
    entity_name : String?
    } derive(
    Debug
    )

    A quota entity: type plus name (null = the default entity, e.g. the cluster-wide default quota).

    ReassignablePartition

    pub(all) struct ReassignablePartition {
    partition_index : Int
    replicas : Array[Int]?
    } derive(
    Debug
    )

    One partition to reassign: replica broker ids, or None to cancel a pending reassignment.

    ReassignablePartitionResponse

    pub struct ReassignablePartitionResponse {
    partition_index : Int
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    ReassignableTopic

    pub(all) struct ReassignableTopic {
    name : String
    partitions : Array[ReassignablePartition]
    } derive(
    Debug
    )

    RebalanceListener

    pub struct RebalanceListener {
    on_assign : (Array[(String, Int)]) -> Unit
    on_revoke : (Array[(String, Int)]) -> Unit
    }

    Rebalance hooks fired around assignment changes: on_revoke with the

    RebalanceListener::default

    RebalanceListener::new

    fn RebalanceListener::new(on_assign~ : (Array[(String, Int)]) -> Unit, on_revoke~ : (Array[(String, Int)]) -> Unit) -> RebalanceListener

    Record

    pub(all) struct Record {
    offset : Int64
    timestamp : Int64
    key : Bytes?
    value : Bytes?
    headers : Array[(Bytes, Bytes)]
    } derive(
    Debug
    )

    Record::key_utf8

    fn Record::key_utf8(self : Record) -> String?

    The record key as UTF-8, when present.

    Record::value_utf8

    fn Record::value_utf8(self : Record) -> String?

    The record value as UTF-8, when present (tombstones decode to None).

    RecordBatchBuilder

    pub struct RecordBatchBuilder {
    base_offset : Int64
    bodies : Array[Bytes]
    body_bytes : Int
    base_timestamp : Int64
    max_timestamp : Int64
    last_offset : Int64
    producer_id : Int64
    producer_epoch : Int
    base_sequence : Int
    transactional : Bool
    } derive(
    Debug
    )

    Incremental batch builder for the producer accumulator: appends records, tracks the encoded size, and finalizes with the CRC.

    RecordBatchBuilder::append

    fn RecordBatchBuilder::append(self : RecordBatchBuilder, timestamp : Int64, key? : Bytes?, value? : Bytes?, headers? : Array[(Bytes, Bytes)]) -> Unit

    Append one record. timestamp is absolute ms since epoch; offsets are assigned sequentially from the builder's base offset.

    RecordBatchBuilder::count

    fn RecordBatchBuilder::count(self : RecordBatchBuilder) -> Int

    Number of records appended so far.

    RecordBatchBuilder::estimated_append_size

    fn RecordBatchBuilder::estimated_append_size(self : RecordBatchBuilder, timestamp : Int64, key? : Bytes?, value? : Bytes?, headers? : Array[(Bytes, Bytes)]) -> Int

    Encoded size that append would add — the record body plus its length varint — without mutating the builder. The accumulator's has-room check for batch_size and buffer_memory accounting.

    RecordBatchBuilder::estimated_size

    fn RecordBatchBuilder::estimated_size(self : RecordBatchBuilder) -> Int

    Upper bound on the finalized batch size: fixed header plus record bodies (header fields other than bodies do not grow with records).

    RecordBatchBuilder::last_assigned_offset

    fn RecordBatchBuilder::last_assigned_offset(self : RecordBatchBuilder) -> Int64

    Highest assigned absolute offset; base_offset - 1 when empty.

    RecordBatchBuilder::new

    fn RecordBatchBuilder::new(base_offset? : Int64) -> RecordBatchBuilder

    RecordBatchBuilder::set_idempotence

    fn RecordBatchBuilder::set_idempotence(self : RecordBatchBuilder, producer_id : Int64, producer_epoch : Int, base_sequence : Int) -> Unit

    Stamp the idempotence identity: the batch's records get sequence numbers base_sequence..base_sequence+count-1 on the wire. Re-stamping (epoch bump after UNKNOWN_PRODUCER_ID) regenerates them at to_bytes.

    RecordBatchBuilder::set_transactional

    fn RecordBatchBuilder::set_transactional(self : RecordBatchBuilder) -> Unit

    Mark the batch transactional (attributes bit 4).

    RecordBatchBuilder::to_bytes

    fn RecordBatchBuilder::to_bytes(self : RecordBatchBuilder) -> Bytes

    Finalize the batch: header with rebased timestamps, CRC32C patched in.

    SaslAuthenticateResult

    pub(all) struct SaslAuthenticateResult {
    error_code : Int
    error_message : String?
    auth_bytes : Bytes?
    session_lifetime_ms : Int64
    }

    SaslConfig

    pub(all) struct SaslConfig {
    mechanism : SaslMechanism
    username : String
    password : String
    oauth_token_provider : () -> String raise?
    }

    impl Debug for SaslConfig

    SaslHandshakeResult

    pub(all) struct SaslHandshakeResult {
    error_code : Int
    mechanisms : Array[String]
    }

    SaslMechanism

    pub(all) enum SaslMechanism {
    Plain
    ScramSha256
    ScramSha512
    OAuthBearer
    } derive(
    Debug
    )

    SASL mechanism. OAUTHBEARER token callbacks arrive with the Phase 1 SASL work; PLAIN and SCRAM use username/password.

    ScramCredentialDeletion

    pub(all) struct ScramCredentialDeletion {
    name : String
    mechanism : Int
    } derive(
    Debug
    )

    Delete one SCRAM credential of a user (one deletion per mechanism).

    ScramCredentialInfo

    pub struct ScramCredentialInfo {
    mechanism : Int
    iterations : Int
    } derive(
    Debug
    )

    Mechanism and iteration count of a stored SCRAM credential.

    ScramCredentialUpsertion

    pub(all) struct ScramCredentialUpsertion {
    name : String
    mechanism : Int
    iterations : Int
    salt : Bytes
    salted_password : Bytes
    } derive(
    Debug
    )

    Insert or replace a SCRAM credential. salt and salted_password follow the wire format (SaltedPassword = Hi(password, salt, iterations)); ScramCredentialUpsertion::from_password derives them from a plaintext password.

    ScramCredentialUpsertion::from_password

    fn ScramCredentialUpsertion::from_password(name : String, mechanism : Int, password : Bytes, iterations? : Int) -> ScramCredentialUpsertion raise

    Build an upsertion from a plaintext password: the salt derives from a hash of the user, mechanism, and wall clock (unique per call, like the SCRAM client nonce), and the salted password is PBKDF2-HMAC per RFC 5802. Brokers accept iteration counts between 4096 and 16384.

    ScramServerFirst

    pub(all) struct ScramServerFirst {
    nonce : String
    salt : Bytes
    iterations : Int
    } derive(
    Debug
    )

    ScramServerFirst::parse

    fn ScramServerFirst::parse(msg : String) -> ScramServerFirst raise

    Parse a server-first-message into its nonce (which must extend the client nonce), salt, and iteration count.

    SecurityProtocol

    pub(all) enum SecurityProtocol {
    Plaintext
    Ssl
    SaslPlaintext
    SaslSsl
    } derive(
    Debug
    )

    Transport security. SASL layers authenticate right after connecting; only plaintext is wired up so far.

    SendHandle

    pub struct SendHandle {
    // private fields
    }

    A cancelable handle to one record's produce result. await returns the broker-assigned offset (or -1 with acks=0). cancel stops the wait and makes await raise — the record itself still goes out, since batches are shared with other senders and records are not retracted.

    SendHandle::cancel

    fn SendHandle::cancel(self : SendHandle) -> Unit

    Stop waiting for this record: a running or later await raises immediately. The record is still delivered if its batch was already in flight — cancellation here means "I no longer care", not "retract".

    SendHandle::on_complete

    fn SendHandle::on_complete(self : SendHandle, callback : async (SendResult) -> Unit) -> Unit

    Run callback with the record's terminal outcome, as a background task in the producer's task group. Fire-and-forget: failures inside the callback do not fail the group.

    SendHandle::wait

    async fn SendHandle::wait(self : SendHandle) -> Int64

    Wait for the sender task to resolve the record. Raises when the handle was cancelled before completion, or with the batch's error.

    SendRecord

    pub(all) struct SendRecord {
    key : Bytes?
    value : Bytes?
    timestamp : Int64?
    partition : Int?
    headers : Array[(Bytes, Bytes)]
    }

    One record for send_all.

    SendRecord::of

    fn SendRecord::of(value~ : Bytes) -> SendRecord

    Defaults for a SendRecord: no key, no headers, wall-clock timestamp.

    SendResult

    pub(all) enum SendResult {
    Sent(Int64)
    Failed(String)
    } derive(
    Debug
    )

    Terminal outcome delivered to a completion callback.

    SettableConfig

    pub(all) struct SettableConfig {
    name : String
    value : String?
    } derive(
    Debug
    )

    One legacy (full-replace) config override.

    SettableConfigResource

    pub(all) struct SettableConfigResource {
    resource_type : Int
    resource_name : String
    configs : Array[SettableConfig]
    } derive(
    Debug
    )

    One resource's full config replacement (AlterConfigs semantics: the given list replaces the resource's overridable configs).

    ShareAckBatch

    pub(all) struct ShareAckBatch {
    first_offset : Int64
    last_offset : Int64
    acknowledge_types : Array[Int]
    } derive(
    Debug
    )

    One offset range of records to acknowledge, with one delivery type per record offset: 0 Gap, 1 Accept, 2 Release, 3 Reject, 4 Renew.

    ShareAckType

    pub(all) enum ShareAckType {
    ShareAccept
    ShareRelease
    ShareReject
    ShareRenew
    } derive(Eq,
    Debug
    )

    The acknowledgement a member makes over an offset range. 0 Gap, 1 Accept, 2 Release, 3 Reject, 4 Renew.

    ShareAcknowledgePartitionResult

    pub struct ShareAcknowledgePartitionResult {
    partition : Int
    error_code : Int
    error_message : String?
    leader_id : Int
    leader_epoch : Int
    } derive(
    Debug
    )

    ShareAcknowledgeResult

    pub struct ShareAcknowledgeResult {
    error_code : Int
    error_message : String?
    acquisition_lock_timeout_ms : Int
    topics : Array[ShareAcknowledgeTopicResult]
    } derive(
    Debug
    )

    ShareAcknowledgeTopicResult

    pub struct ShareAcknowledgeTopicResult {
    topic_id : Uuid
    partitions : Array[ShareAcknowledgePartitionResult]
    } derive(
    Debug
    )

    One topic's acknowledgement outcome.

    ShareAcquiredRange

    pub(all) struct ShareAcquiredRange {
    first_offset : Int64
    last_offset : Int64
    delivery_count : Int
    } derive(
    Debug
    )

    One acquired offset range in a share fetch response.

    ShareConsumer

    pub struct ShareConsumer {
    topic : String
    topic_id : Uuid
    group_id : String
    start_from : StartFrom
    max_queue_size : Int
    delivery_count_limit : Int
    request_timeout_ms : Int
    retries : Int
    retry_backoff_ms : Int
    retry_backoff_max_ms : Int
    group :
    TaskGroup
    [Unit]
    partitions : Array[PartitionInfo]
    closed : Bool
    // private fields
    }

    The share consumer: connect, subscribe to its group, then poll and acknowledge.

    ShareConsumer::acknowledge

    async fn ShareConsumer::acknowledge(self : ShareConsumer, records : Array[ShareRecord], action : ShareAckType) -> Array[ShareAcknowledgeTopicResult]

    Acknowledge a set of records with one delivery action, sending a ShareAcknowledge request. records must have been returned by poll() and still be in flight. Returns the per-partition result.

    ShareConsumer::assignment

    fn ShareConsumer::assignment(self : ShareConsumer) -> Array[(String, Int)]

    The topic-partitions the coordinator currently assigns to this member.

    ShareConsumer::close

    fn ShareConsumer::close(self : ShareConsumer) -> Unit

    Stop the consumer and leave the group.

    ShareConsumer::connect_with_config

    async fn ShareConsumer::connect_with_config(group~ :
    TaskGroup
    [Unit], config : ShareConsumerConfig) -> ShareConsumer

    Connect a share consumer to the bootstrap set and resolve the topic's partition leaders. The membership loop joins group on subscribe.

    ShareConsumer::member_identity

    fn ShareConsumer::member_identity(self : ShareConsumer) -> String

    This member's generated id; empty while not subscribed.

    ShareConsumer::membership_error

    fn ShareConsumer::membership_error(self : ShareConsumer) -> String?

    The last fatal membership error, if the loop stopped on one.

    ShareConsumer::poll

    async fn ShareConsumer::poll(self : ShareConsumer, max_wait_ms? : Int, max_records? : Int) -> Array[ShareRecord]

    Poll: acquire records for every assigned partition via ShareFetch v2 and return them. Records land in the in-flight queue until acknowledge() drains them. Records at or past the delivery limit are auto-rejected and never surfaced.

    ShareConsumer::subscribe

    fn ShareConsumer::subscribe(self : ShareConsumer) -> Unit

    Subscribe to the share group and start the membership loop.

    ShareConsumerConfig

    pub struct ShareConsumerConfig {
    common : CommonConfig
    topic : String
    group_id : String
    start_from : StartFrom
    max_queue_size : Int
    delivery_count_limit : Int
    request_timeout_ms : Int
    } derive(
    Debug
    )

    Share consumer settings on top of the shared transport config.

    ShareConsumerConfig::new

    fn ShareConsumerConfig::new(bootstrap_servers : Array[String], topic : String, group_id : String, start_from? : StartFrom, request_timeout_ms? : Int, security_protocol? : SecurityProtocol, sasl? : SaslConfig?, tls? : TlsClientOptions?, metadata_max_age_ms? : Int, max_queue_size? : Int, delivery_count_limit? : Int) -> ShareConsumerConfig raise

    ShareFetchPartition

    pub(all) struct ShareFetchPartition {
    partition : Int
    acknowledgment_batches : Array[ShareAckBatch]
    } derive(
    Debug
    )

    One partition's acknowledgment batches in a share-fetch or share-acknowledge request.

    ShareFetchPartitionResult

    pub struct ShareFetchPartitionResult {
    partition : Int
    error_code : Int
    error_message : String?
    acknowledge_error_code : Int
    acknowledge_error_message : String?
    leader_id : Int
    leader_epoch : Int
    records : Array[Record]
    batches : Array[DecodedBatch]
    records_complete : Bool
    acquired : Array[ShareAcquiredRange]
    } derive(
    Debug
    )

    ShareFetchResult

    pub struct ShareFetchResult {
    error_code : Int
    error_message : String?
    acquisition_lock_timeout_ms : Int
    topics : Array[ShareFetchTopicResult]
    } derive(
    Debug
    )

    One share fetch response body. Records decode through the shared record-batch machinery; acquired ranges carry their delivery count.

    ShareFetchTopic

    pub(all) struct ShareFetchTopic {
    topic_id : Uuid
    partitions : Array[ShareFetchPartition]
    } derive(
    Debug
    )

    One topic to share-fetch: topic-id addressed, so the cluster must resolve id=name from metadata before building the request.

    ShareFetchTopicResult

    pub struct ShareFetchTopicResult {
    topic_id : Uuid
    partitions : Array[ShareFetchPartitionResult]
    } derive(
    Debug
    )

    ShareForgottenTopic

    pub(all) struct ShareForgottenTopic {
    topic_id : Uuid
    partitions : Array[Int]
    } derive(
    Debug
    )

    One topic's partitions to drop from the established share session.

    ShareGroupHeartbeatResult

    pub struct ShareGroupHeartbeatResult {
    error_code : Int
    error_message : String?
    member_id : String
    member_epoch : Int
    heartbeat_interval_ms : Int
    assignment : Array[ShareHeartbeatTopicPartitions]
    } derive(
    Debug
    )

    One share-group heartbeat outcome: identity/epoch reconciliation, the server's heartbeat interval, and the (possibly empty) topic assignment.

    ShareHeartbeatTopicPartitions

    pub(all) struct ShareHeartbeatTopicPartitions {
    topic_id : Uuid
    partitions : Array[Int]
    } derive(
    Debug
    )

    The share coordinator's pushed assignment: topic-id addressed partitions per topic.

    ShareOffsetAlterPartition

    pub(all) struct ShareOffsetAlterPartition {
    partition : Int
    start_offset : Int64
    } derive(
    Debug
    )

    One partition's start offset to alter.

    ShareOffsetAlterPartitionResult

    pub(all) struct ShareOffsetAlterPartitionResult {
    partition : Int
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    ShareOffsetAlterResult

    pub struct ShareOffsetAlterResult {
    error_code : Int
    error_message : String?
    topics : Array[ShareOffsetAlterTopicResult]
    } derive(
    Debug
    )

    ShareOffsetAlterTopic

    pub(all) struct ShareOffsetAlterTopic {
    name : String
    partitions : Array[ShareOffsetAlterPartition]
    } derive(
    Debug
    )

    One topic to alter share offsets for.

    ShareOffsetAlterTopicResult

    pub(all) struct ShareOffsetAlterTopicResult {
    name : String
    topic_id : Uuid
    partitions : Array[ShareOffsetAlterPartitionResult]
    } derive(
    Debug
    )

    ShareOffsetDeleteResult

    pub struct ShareOffsetDeleteResult {
    error_code : Int
    error_message : String?
    topics : Array[ShareOffsetDeleteTopicResult]
    } derive(
    Debug
    )

    ShareOffsetDeleteTopicResult

    pub(all) struct ShareOffsetDeleteTopicResult {
    name : String
    topic_id : Uuid
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    ShareOffsetDescribeGroup

    pub(all) struct ShareOffsetDescribeGroup {
    group_id : String
    topics : Array[ShareOffsetDescribeTopic]?
    } derive(
    Debug
    )

    One group in a DescribeShareGroupOffsets request; None topics means all topic-partitions.

    ShareOffsetDescribeGroupResult

    pub(all) struct ShareOffsetDescribeGroupResult {
    group_id : String
    topics : Array[ShareOffsetDescribeTopicResult]
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    ShareOffsetDescribePartition

    pub(all) struct ShareOffsetDescribePartition {
    partition : Int
    start_offset : Int64
    leader_epoch : Int
    lag : Int64
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    One described partition's share start offset.

    ShareOffsetDescribeTopic

    pub(all) struct ShareOffsetDescribeTopic {
    name : String
    partitions : Array[Int]
    } derive(
    Debug
    )

    One topic wanted in a DescribeShareGroupOffsets request: its name and the partitions to describe (empty = all).

    ShareOffsetDescribeTopicResult

    pub(all) struct ShareOffsetDescribeTopicResult {
    name : String
    topic_id : Uuid
    partitions : Array[ShareOffsetDescribePartition]
    } derive(
    Debug
    )

    ShareRecord

    pub struct ShareRecord {
    partition : Int
    offset : Int64
    timestamp : Int64
    key : Bytes?
    value : Bytes?
    headers : Array[(Bytes, Bytes)]
    } derive(
    Debug
    )

    One record delivered to this share consumer, with the partition it came from so the caller can acknowledge it later.

    ShareSession

    pub struct ShareSession {
    epoch : Int
    } derive(
    Debug
    )

    One per-leader share session: epoch (0 opens, >0 continues, -1 closes) and the partitions the broker has in the session. Rebuilt (from epoch 0) whenever the broker reports a session error.

    ShareSession::new

    StartFrom

    pub(all) enum StartFrom {
    Earliest
    Latest
    } derive(
    Debug
    )

    SyncGroupAssignment

    pub(all) struct SyncGroupAssignment {
    member_id : String
    assignment : Bytes
    } derive(
    Debug
    )

    One member's assignment in a SyncGroup request (the leader sends all).

    SyncGroupResult

    pub struct SyncGroupResult {
    error_code : Int
    protocol_name : String
    assignment : Bytes
    } derive(
    Debug
    )

    TelemetryClient

    pub struct TelemetryClient {
    cluster : ClusterClient
    group :
    TaskGroup
    [Unit]
    max_push_bytes : Int
    metrics_provider : () -> Bytes
    // private fields
    }

    TelemetryClient::close

    fn TelemetryClient::close(self : TelemetryClient) -> Unit

    Stop the telemetry client and send the terminating push.

    TelemetryClient::connect_with_config

    async fn TelemetryClient::connect_with_config(group~ :
    TaskGroup
    [Unit], config : TelemetryClientConfig) -> TelemetryClient

    Connect the telemetry client and fetch its first subscription. The push loop joins group once it runs.

    TelemetryClient::run

    fn TelemetryClient::run(self : TelemetryClient) -> Unit

    Start pushing metrics: fetch the subscription (best effort) and run the push loop in group.

    TelemetryClientConfig

    pub struct TelemetryClientConfig {
    common : CommonConfig
    client_instance_id : Uuid
    max_push_bytes : Int
    metrics_provider : () -> Bytes
    }

    Telemetry client settings on top of the shared transport config.

    TelemetryClientConfig::new

    fn TelemetryClientConfig::new(bootstrap_servers : Array[String], client_instance_id? : Uuid, max_push_bytes? : Int, metrics_provider~ : () -> Bytes, request_timeout_ms? : Int, security_protocol? : SecurityProtocol, sasl? : SaslConfig?, tls? : TlsClientOptions?, metadata_max_age_ms? : Int) -> TelemetryClientConfig raise

    TelemetrySubscription

    pub struct TelemetrySubscription {
    error_code : Int
    client_instance_id : Uuid
    subscription_id : Int
    accepted_compression_types : Array[Int]
    push_interval_ms : Int
    telemetry_max_bytes : Int
    delta_temporality : Bool
    requested_metrics : Array[String]
    } derive(
    Debug
    )

    TlsClientOptions

    pub(all) struct TlsClientOptions {
    server_name : String
    verify_certificates : Bool
    ca_pem_file : String?
    } derive(
    Debug
    )

    TLS settings for a broker connection. server_name drives SNI and certificate verification; ca_pem_file overrides the system trust roots with a custom CA bundle.

    TlsClientOptions::new

    fn TlsClientOptions::new(server_name : String, verify_certificates? : Bool, ca_pem_file? : String?) -> TlsClientOptions

    TopicMetadata

    pub struct TopicMetadata {
    name : String
    error_code : Int
    topic_id : Uuid
    is_internal : Bool
    partitions : Array[PartitionInfo]
    }

    TopicPartitionCursor

    pub(all) struct TopicPartitionCursor {
    topic_name : String
    partition_index : Int
    } derive(
    Debug
    )

    Cursor for paginated DescribeTopicPartitions responses: the topic and partition index the next request resumes from.

    TxnOffset

    pub(all) struct TxnOffset {
    partition : Int
    offset : Int64
    } derive(
    Debug
    )

    One offset destined for TxnOffsetCommit within a transaction.

    TxnPartitionResult

    pub struct TxnPartitionResult {
    topic : String
    partition : Int
    error_code : Int
    } derive(
    Debug
    )

    One partition's outcome from AddPartitionsToTxn / TxnOffsetCommit.

    UnregisterBrokerResult

    pub struct UnregisterBrokerResult {
    error_code : Int
    error_message : String?
    } derive(
    Debug
    )

    Uuid

    pub struct Uuid {
    bytes : Bytes
    } derive(Compare, Eq, Hash,
    Debug
    )

    impl Show for Uuid

    Uuid::from_bytes

    fn Uuid::from_bytes(bytes : Bytes) -> Uuid raise
    DecodeError

    Wrap exactly 16 bytes; anything else is a wire-level violation.

    Uuid::parse

    Parse the canonical 22-char form (as produced by Show). The zero padding in the trailing character's low bits is ignored, like Java's decoder.

    Uuid::to_bytes

    fn Uuid::to_bytes(self : Uuid) -> Bytes

    Uuid::zero

    fn Uuid::zero() -> Uuid

    The all-zero uuid, Kafka's sentinel for "no id".

    ACL_OPERATION_ALL

    let ACL_OPERATION_ALL : Int

    ACL_OPERATION_ALTER

    let ACL_OPERATION_ALTER : Int

    ACL_OPERATION_ALTER_CONFIGS

    let ACL_OPERATION_ALTER_CONFIGS : Int

    ACL_OPERATION_ANY

    let ACL_OPERATION_ANY : Int

    ACL_OPERATION_CLUSTER_ACTION

    let ACL_OPERATION_CLUSTER_ACTION : Int

    ACL_OPERATION_CREATE

    let ACL_OPERATION_CREATE : Int

    ACL_OPERATION_CREATE_TOKENS

    let ACL_OPERATION_CREATE_TOKENS : Int

    ACL_OPERATION_DELETE

    let ACL_OPERATION_DELETE : Int

    ACL_OPERATION_DESCRIBE

    let ACL_OPERATION_DESCRIBE : Int

    ACL_OPERATION_DESCRIBE_CONFIGS

    let ACL_OPERATION_DESCRIBE_CONFIGS : Int

    ACL_OPERATION_DESCRIBE_TOKENS

    let ACL_OPERATION_DESCRIBE_TOKENS : Int

    ACL_OPERATION_IDEMPOTENT_WRITE

    let ACL_OPERATION_IDEMPOTENT_WRITE : Int

    ACL_OPERATION_READ

    let ACL_OPERATION_READ : Int

    ACL_OPERATION_TWO_PHASE_COMMIT

    let ACL_OPERATION_TWO_PHASE_COMMIT : Int

    KIP-939 era; supported by 4.3 brokers.

    ACL_OPERATION_UNKNOWN

    let ACL_OPERATION_UNKNOWN : Int

    ACL operations (AclOperation byte values).

    ACL_OPERATION_WRITE

    let ACL_OPERATION_WRITE : Int

    ACL_PATTERN_ANY

    let ACL_PATTERN_ANY : Int

    ACL_PATTERN_LITERAL

    let ACL_PATTERN_LITERAL : Int

    ACL_PATTERN_MATCH

    let ACL_PATTERN_MATCH : Int

    MATCH in filters; never describes a stored binding.

    ACL_PATTERN_PREFIXED

    let ACL_PATTERN_PREFIXED : Int

    ACL_PATTERN_UNKNOWN

    let ACL_PATTERN_UNKNOWN : Int

    Resource pattern types (PatternType byte values).

    ACL_PERMISSION_ALLOW

    let ACL_PERMISSION_ALLOW : Int

    ACL_PERMISSION_ANY

    let ACL_PERMISSION_ANY : Int

    ACL_PERMISSION_DENY

    let ACL_PERMISSION_DENY : Int

    ACL_PERMISSION_UNKNOWN

    let ACL_PERMISSION_UNKNOWN : Int

    ACL permission types (AclPermissionType byte values).

    ACL_RESOURCE_ANY

    let ACL_RESOURCE_ANY : Int

    ACL_RESOURCE_CLUSTER

    let ACL_RESOURCE_CLUSTER : Int

    ACL_RESOURCE_DELEGATION_TOKEN

    let ACL_RESOURCE_DELEGATION_TOKEN : Int

    ACL_RESOURCE_GROUP

    let ACL_RESOURCE_GROUP : Int

    ACL_RESOURCE_TOPIC

    let ACL_RESOURCE_TOPIC : Int

    ACL_RESOURCE_TRANSACTIONAL_ID

    let ACL_RESOURCE_TRANSACTIONAL_ID : Int

    ACL_RESOURCE_UNKNOWN

    let ACL_RESOURCE_UNKNOWN : Int

    ACL resource types (ResourceType byte values).

    ACL_RESOURCE_USER

    let ACL_RESOURCE_USER : Int

    v3 and newer brokers.

    API_ADD_OFFSETS_TO_TXN

    let API_ADD_OFFSETS_TO_TXN : Int

    API_ADD_PARTITIONS_TO_TXN

    let API_ADD_PARTITIONS_TO_TXN : Int

    API_ALTER_CLIENT_QUOTAS

    let API_ALTER_CLIENT_QUOTAS : Int

    API_ALTER_CONFIGS

    let API_ALTER_CONFIGS : Int

    API_ALTER_PARTITION_REASSIGNMENTS

    let API_ALTER_PARTITION_REASSIGNMENTS : Int

    API_ALTER_SHARE_GROUP_OFFSETS

    let API_ALTER_SHARE_GROUP_OFFSETS : Int

    API_ALTER_USER_SCRAM_CREDENTIALS

    let API_ALTER_USER_SCRAM_CREDENTIALS : Int

    API_API_VERSIONS

    let API_API_VERSIONS : Int

    API_CONSUMER_GROUP_DESCRIBE

    let API_CONSUMER_GROUP_DESCRIBE : Int

    API_CONSUMER_GROUP_HEARTBEAT

    let API_CONSUMER_GROUP_HEARTBEAT : Int

    API_CREATE_ACLS

    let API_CREATE_ACLS : Int

    API_CREATE_PARTITIONS

    let API_CREATE_PARTITIONS : Int

    API_CREATE_TOPICS

    let API_CREATE_TOPICS : Int

    API_DELETE_ACLS

    let API_DELETE_ACLS : Int

    API_DELETE_GROUPS

    let API_DELETE_GROUPS : Int

    API_DELETE_RECORDS

    let API_DELETE_RECORDS : Int

    API_DELETE_SHARE_GROUP_OFFSETS

    let API_DELETE_SHARE_GROUP_OFFSETS : Int

    API_DELETE_TOPICS

    let API_DELETE_TOPICS : Int

    API_DESCRIBE_ACLS

    let API_DESCRIBE_ACLS : Int

    API_DESCRIBE_CLIENT_QUOTAS

    let API_DESCRIBE_CLIENT_QUOTAS : Int

    API_DESCRIBE_CLUSTER

    let API_DESCRIBE_CLUSTER : Int

    API_DESCRIBE_CONFIGS

    let API_DESCRIBE_CONFIGS : Int

    API_DESCRIBE_GROUPS

    let API_DESCRIBE_GROUPS : Int

    API_DESCRIBE_LOG_DIRS

    let API_DESCRIBE_LOG_DIRS : Int

    API_DESCRIBE_PRODUCERS

    let API_DESCRIBE_PRODUCERS : Int

    API_DESCRIBE_QUORUM

    let API_DESCRIBE_QUORUM : Int

    API_DESCRIBE_SHARE_GROUP_OFFSETS

    let API_DESCRIBE_SHARE_GROUP_OFFSETS : Int

    API_DESCRIBE_TOPIC_PARTITIONS

    let API_DESCRIBE_TOPIC_PARTITIONS : Int

    API_DESCRIBE_TRANSACTIONS

    let API_DESCRIBE_TRANSACTIONS : Int

    API_DESCRIBE_USER_SCRAM_CREDENTIALS

    let API_DESCRIBE_USER_SCRAM_CREDENTIALS : Int

    API_ELECT_LEADERS

    let API_ELECT_LEADERS : Int

    API_END_TXN

    let API_END_TXN : Int

    API_FETCH

    let API_FETCH : Int

    API_FIND_COORDINATOR

    let API_FIND_COORDINATOR : Int

    API_GET_TELEMETRY_SUBSCRIPTIONS

    let API_GET_TELEMETRY_SUBSCRIPTIONS : Int

    API_HEARTBEAT

    let API_HEARTBEAT : Int

    API_INCREMENTAL_ALTER_CONFIGS

    let API_INCREMENTAL_ALTER_CONFIGS : Int

    API_INIT_PRODUCER_ID

    let API_INIT_PRODUCER_ID : Int

    API_JOIN_GROUP

    let API_JOIN_GROUP : Int

    API_LEAVE_GROUP

    let API_LEAVE_GROUP : Int

    API_LIST_CONFIG_RESOURCES

    let API_LIST_CONFIG_RESOURCES : Int

    API_LIST_GROUPS

    let API_LIST_GROUPS : Int

    API_LIST_OFFSETS

    let API_LIST_OFFSETS : Int

    API_LIST_PARTITION_REASSIGNMENTS

    let API_LIST_PARTITION_REASSIGNMENTS : Int

    API_LIST_TRANSACTIONS

    let API_LIST_TRANSACTIONS : Int

    API_METADATA

    let API_METADATA : Int

    API_OFFSET_COMMIT

    let API_OFFSET_COMMIT : Int

    API_OFFSET_DELETE

    let API_OFFSET_DELETE : Int

    API_OFFSET_FETCH

    let API_OFFSET_FETCH : Int

    API_OFFSET_FOR_LEADER_EPOCH

    let API_OFFSET_FOR_LEADER_EPOCH : Int

    API_PRODUCE

    let API_PRODUCE : Int

    API_PUSH_TELEMETRY

    let API_PUSH_TELEMETRY : Int

    API_SASL_AUTHENTICATE

    let API_SASL_AUTHENTICATE : Int

    API_SASL_HANDSHAKE

    let API_SASL_HANDSHAKE : Int

    API_SHARE_ACKNOWLEDGE

    let API_SHARE_ACKNOWLEDGE : Int

    API_SHARE_FETCH

    let API_SHARE_FETCH : Int

    API_SHARE_GROUP_HEARTBEAT

    let API_SHARE_GROUP_HEARTBEAT : Int

    API_SYNC_GROUP

    let API_SYNC_GROUP : Int

    API_TXN_OFFSET_COMMIT

    let API_TXN_OFFSET_COMMIT : Int

    API_UNREGISTER_BROKER

    let API_UNREGISTER_BROKER : Int

    API_UPDATE_FEATURES

    let API_UPDATE_FEATURES : Int

    AUTHORIZED_OPERATIONS_NONE

    let AUTHORIZED_OPERATIONS_NONE : Int

    The AuthorizedOperations sentinel a broker sends when the request did not ask for authorized operations, or the group errored (Integer.MIN_VALUE in the Java client).

    CONFIG_OP_APPEND

    let CONFIG_OP_APPEND : Int

    CONFIG_OP_DELETE

    let CONFIG_OP_DELETE : Int

    CONFIG_OP_SET

    let CONFIG_OP_SET : Int

    Incremental config operations (AlterConfigOp.OpType byte values).

    CONFIG_OP_SUBTRACT

    let CONFIG_OP_SUBTRACT : Int

    CONFIG_RESOURCE_BROKER

    let CONFIG_RESOURCE_BROKER : Int

    CONFIG_RESOURCE_BROKER_LOGGER

    let CONFIG_RESOURCE_BROKER_LOGGER : Int

    CONFIG_RESOURCE_CLIENT_METRICS

    let CONFIG_RESOURCE_CLIENT_METRICS : Int

    CONFIG_RESOURCE_GROUP

    let CONFIG_RESOURCE_GROUP : Int

    CONFIG_RESOURCE_TOPIC

    let CONFIG_RESOURCE_TOPIC : Int

    CONFIG_RESOURCE_UNKNOWN

    let CONFIG_RESOURCE_UNKNOWN : Int

    Config resource types (ConfigResource.Type byte values).

    CONSUMER_PROTOCOL_ASSIGNMENT_VERSION

    let CONSUMER_PROTOCOL_ASSIGNMENT_VERSION : Int

    CONSUMER_PROTOCOL_SUBSCRIPTION_VERSION

    let CONSUMER_PROTOCOL_SUBSCRIPTION_VERSION : Int

    ELECTION_PREFERRED

    let ELECTION_PREFERRED : Int

    Leader election types (ElectionType byte values).

    ELECTION_UNCLEAN

    let ELECTION_UNCLEAN : Int

    ENDPOINT_TYPE_BROKERS

    let ENDPOINT_TYPE_BROKERS : Int

    DescribeCluster endpoint types (schema: 1 = brokers, 2 = controllers).

    ENDPOINT_TYPE_CONTROLLERS

    let ENDPOINT_TYPE_CONTROLLERS : Int

    FEATURE_SAFE_DOWNGRADE

    let FEATURE_SAFE_DOWNGRADE : Int

    FEATURE_UNSAFE_DOWNGRADE

    let FEATURE_UNSAFE_DOWNGRADE : Int

    FEATURE_UPGRADE

    let FEATURE_UPGRADE : Int

    UpdateFeatures upgrade types (UpdateFeaturesRequest.UpgradeType).

    FETCH_FULL_EPOCH

    let FETCH_FULL_EPOCH : Int

    Fetch epoch of a sessionless ("full") request.

    FETCH_SESSION_ID_NOT_FOUND

    let FETCH_SESSION_ID_NOT_FOUND : Int

    GROUP_ID_NOT_FOUND

    let GROUP_ID_NOT_FOUND : Int

    GROUP_ID_NOT_FOUND: what v6 reports for a group the coordinator does not hold as a classic group (KIP-1043), including KIP-848 consumer groups.

    GROUP_MEMBER_TYPE_CLASSIC

    let GROUP_MEMBER_TYPE_CLASSIC : Int

    GROUP_MEMBER_TYPE_CONSUMER

    let GROUP_MEMBER_TYPE_CONSUMER : Int

    GROUP_MEMBER_TYPE_UNKNOWN

    let GROUP_MEMBER_TYPE_UNKNOWN : Int

    MemberType values from ConsumerGroupDescribe v1 (KIP-1099): a group migrating between protocols can hold both kinds at once.

    INVALID_FETCH_SESSION_EPOCH

    let INVALID_FETCH_SESSION_EPOCH : Int

    OFFSET_EARLIEST

    let OFFSET_EARLIEST : Int64

    Sentinel timestamps understood by ListOffsets.

    OFFSET_EARLIEST_PENDING_UPLOAD

    let OFFSET_EARLIEST_PENDING_UPLOAD : Int64

    Earliest pending upload offset (KIP-1023, v11+).

    OFFSET_LAST_TIERED

    let OFFSET_LAST_TIERED : Int64

    Last tiered offset (KIP-1005, v9+).

    OFFSET_LATEST

    let OFFSET_LATEST : Int64

    OFFSET_LOCAL_LOG_START

    let OFFSET_LOCAL_LOG_START : Int64

    Earliest log start offset still in the local log (KIP-405, v8+).

    OFFSET_MAX_TIMESTAMP

    let OFFSET_MAX_TIMESTAMP : Int64

    Offset of the record with the largest timestamp (KIP-734, v7+).

    QUOTA_ENTITY_CLIENT_ID

    let QUOTA_ENTITY_CLIENT_ID : String

    QUOTA_ENTITY_IP

    let QUOTA_ENTITY_IP : String

    QUOTA_ENTITY_USER

    let QUOTA_ENTITY_USER : String

    Quota entity types (ClientQuotaEntity.java).

    QUOTA_MATCH_ANY

    let QUOTA_MATCH_ANY : Int

    QUOTA_MATCH_DEFAULT

    let QUOTA_MATCH_DEFAULT : Int

    QUOTA_MATCH_EXACT

    let QUOTA_MATCH_EXACT : Int

    Quota filter match types (DescribeClientQuotas MatchType values).

    SCRAM_MECHANISM_SHA_256

    let SCRAM_MECHANISM_SHA_256 : Int

    SCRAM mechanisms (ScramMechanism.java byte values).

    SCRAM_MECHANISM_SHA_512

    let SCRAM_MECHANISM_SHA_512 : Int

    backoff_ms

    fn backoff_ms(base_ms : Int, max_ms : Int, attempt : Int) -> Int

    Pure exponential growth: base_ms shifted by attempt, capped at max_ms (and at a shift ceiling so large attempts cannot overflow).

    collect_committed

    fn collect_committed(batches : Array[DecodedBatch], aborted : Array[AbortedTx]) -> Array[Record]

    Read-committed primitive: flatten batches to records, dropping control batches (they carry markers, not data) and every record of an aborted transaction — a transactional batch is aborted when its producer id appears in aborted and the record offset reaches that entry's first_offset. The Fetch response's aborted-tx list feeds aborted; the caller bookkeeps producerId/firstOffset across polls.

    compute_assignment

    fn compute_assignment(assignor : Assignor, members : Array[Assignee], topic_partitions : Map[String, Int], owned? : Map[String, Array[(String, Int)]]) -> Map[String, Array[(String, Int)]]

    Compute a full assignment: member id -> (topic, partition) pairs. owned carries the members' current assignments for stickiness (empty for range/round-robin; cooperative revocation handled by the caller).

    connect_bootstrap

    async fn connect_bootstrap(servers : BootstrapServers, client_id : String, timeout_ms? : Int, sasl? : SaslConfig?, use_tls? : Bool, tls? : TlsClientOptions?) -> BrokerConnection

    Dial the bootstrap servers in rotating order; the first connection that succeeds wins. Raises the last failure if every entry refuses.

    decode_add_offsets_to_txn_response

    fn decode_add_offsets_to_txn_response(d :
    Decoder
    ) -> (Int, Int) raise

    Decode an AddOffsetsToTxn v4 response body: the top-level error code plus the throttle hint.

    decode_add_partitions_to_txn_response

    fn decode_add_partitions_to_txn_response(d :
    Decoder
    ) -> (Array[TxnPartitionResult], Int) raise

    Decode an AddPartitionsToTxn v3 response body: per-partition error codes under the v3-and-below topic results (v4+ restructures the response for the broker-batch API), plus the throttle hint.

    decode_alter_client_quotas_response

    fn decode_alter_client_quotas_response(version : Int, d :
    Decoder
    ) -> (Array[AlterClientQuotasResult], Int) raise

    Decode an AlterClientQuotas v0-v1 response body: one result per entry, echoing its entity.

    decode_alter_configs_response

    fn decode_alter_configs_response(d :
    Decoder
    ) -> (Array[AlterConfigsResult], Int) raise

    Decode an AlterConfigs v2 response body (same shape as IncrementalAlterConfigs).

    decode_alter_partition_reassignments_response

    fn decode_alter_partition_reassignments_response(version : Int, d :
    Decoder
    ) -> (AdminReassignmentResult, Int) raise

    Decode an AlterPartitionReassignments v0/v1 response body.

    decode_alter_share_group_offsets_response

    fn decode_alter_share_group_offsets_response(d :
    Decoder
    ) -> (ShareOffsetAlterResult, Int) raise

    Decode an AlterShareGroupOffsets v0 response body.

    decode_alter_user_scram_response

    fn decode_alter_user_scram_response(d :
    Decoder
    ) -> (Array[AlterUserScramResult], Int) raise

    Decode an AlterUserScramCredentials v0 response body: one result per deletion and upsertion.

    decode_api_versions_response

    fn decode_api_versions_response(d :
    Decoder
    ) -> (BrokerVersions, Int) raise

    Decode an ApiVersions v3 response; response header is v0 (no tag buffer). Returns the broker's advertised version ranges plus the throttle hint in milliseconds. Version validation is not done here: requests negotiate against the ranges via BrokerVersions::pick.

    decode_consumer_group_describe_response

    fn decode_consumer_group_describe_response(d :
    Decoder
    ) -> (Array[AdminConsumerGroupDescription], Int) raise

    Decode a ConsumerGroupDescribe v1 response body: one description per requested group, in request order.

    decode_consumer_group_heartbeat_response

    fn decode_consumer_group_heartbeat_response(d :
    Decoder
    ) -> (ConsumerGroupHeartbeatResult, Int) raise

    Decode a ConsumerGroupHeartbeat response body.

    decode_consumer_protocol_assignment

    fn decode_consumer_protocol_assignment(data : Bytes) -> Array[(String, Array[Int])] raise

    Parse a ConsumerProtocolAssignment: topic partitions per member.

    decode_consumer_protocol_subscription

    fn decode_consumer_protocol_subscription(data : Bytes) -> Array[String] raise

    Parse a ConsumerProtocolSubscription: the subscribed topic names.

    decode_create_acls_response

    fn decode_create_acls_response(d :
    Decoder
    ) -> (Array[CreateAclsResult], Int) raise

    Decode a CreateAcls v2/v3 response body: one result per creation.

    decode_create_partitions_response

    fn decode_create_partitions_response(d :
    Decoder
    ) -> (Array[CreatePartitionsResult], Int) raise

    Decode a CreatePartitions v3 response body.

    decode_create_topics_response

    fn decode_create_topics_response(d :
    Decoder
    ) -> (Array[CreateTopicsResult], Int) raise

    Decode a CreateTopics v7 response body: per-topic results (the echoed config block is skipped — the topic configs come back through DescribeConfigs).

    decode_delete_acls_response

    fn decode_delete_acls_response(d :
    Decoder
    ) -> (Array[DeleteAclsFilterResult], Int) raise

    Decode a DeleteAcls v2/v3 response body: one result per filter, each carrying the ACLs it matched and deleted.

    decode_delete_groups_response

    fn decode_delete_groups_response(d :
    Decoder
    ) -> (Array[AdminDeletedGroup], Int) raise

    Decode a DeleteGroups v2 response body: one result per requested group, in request order, with per-group error codes as values.

    decode_delete_records_response

    fn decode_delete_records_response(d :
    Decoder
    ) -> (Array[DeleteRecordsResult], Int) raise

    Decode a DeleteRecords v2 response body.

    decode_delete_share_group_offsets_response

    fn decode_delete_share_group_offsets_response(d :
    Decoder
    ) -> (ShareOffsetDeleteResult, Int) raise

    Decode a DeleteShareGroupOffsets v0 response body.

    decode_delete_topics_response

    fn decode_delete_topics_response(d :
    Decoder
    ) -> (Array[DeleteTopicsResult], Int) raise

    Decode a DeleteTopics v6 response body.

    decode_describe_acls_response

    fn decode_describe_acls_response(d :
    Decoder
    ) -> (DescribeAclsResult, Int) raise

    Decode a DescribeAcls v2/v3 response body.

    decode_describe_client_quotas_response

    fn decode_describe_client_quotas_response(version : Int, d :
    Decoder
    ) -> (DescribeClientQuotasResult, Int) raise

    Decode a DescribeClientQuotas v0-v1 response body. The entries array is nullable (the broker sends null on errors); a null decodes as empty.

    decode_describe_cluster_response

    fn decode_describe_cluster_response(version : Int, d :
    Decoder
    ) -> (AdminClusterDescription, Int) raise

    Decode a DescribeCluster v0-v2 response body.

    decode_describe_configs_response

    fn decode_describe_configs_response(d :
    Decoder
    ) -> (Array[AdminConfigsResult], Int) raise

    Decode a DescribeConfigs v4 response body.

    decode_describe_groups_response

    fn decode_describe_groups_response(d :
    Decoder
    ) -> (Array[AdminGroupDescription], Int) raise

    Decode a DescribeGroups v6 response body: one description per requested group, in request order.

    decode_describe_log_dirs_response

    fn decode_describe_log_dirs_response(version : Int, d :
    Decoder
    ) -> (AdminLogDirs, Int) raise

    Decode a DescribeLogDirs v2-v5 response body.

    decode_describe_producers_response

    fn decode_describe_producers_response(d :
    Decoder
    ) -> (Array[AdminDescribeProducersTopic], Int) raise

    Decode a DescribeProducers v0 response body: one topic per requested topic, one partition per requested partition index, with the active producers and per-partition error codes as values.

    decode_describe_quorum_response

    fn decode_describe_quorum_response(d :
    Decoder
    ) -> AdminQuorumDescription raise

    Decode a DescribeQuorum v2 response body. Note: this API carries no throttle_time_ms.

    decode_describe_share_group_offsets_response

    fn decode_describe_share_group_offsets_response(version : Int, d :
    Decoder
    ) -> (Array[ShareOffsetDescribeGroupResult], Int) raise

    Decode a DescribeShareGroupOffsets v0/v1 response body. Lag defaults to -1 in v0.

    decode_describe_topic_partitions_response

    fn decode_describe_topic_partitions_response(d :
    Decoder
    ) -> (DescribeTopicPartitions, Int) raise

    Decode a DescribeTopicPartitions v0 response body. Partition entries carry two nullable ELR arrays (skipped); a null next cursor means the listing is complete. Returns the page plus the throttle hint.

    decode_describe_transactions_response

    fn decode_describe_transactions_response(d :
    Decoder
    ) -> (Array[AdminDescribeTransaction], Int) raise

    Decode a DescribeTransactions v0 response body: one transaction state per requested transactional id, with its error code, state, timeout, start time, producer id/epoch, and the topic-partitions it currently spans.

    decode_describe_user_scram_response

    fn decode_describe_user_scram_response(d :
    Decoder
    ) -> (DescribeUserScramResult, Int) raise

    Decode a DescribeUserScramCredentials v0 response body: one result per user, each with its credential infos.

    decode_elect_leaders_response

    fn decode_elect_leaders_response(d :
    Decoder
    ) -> (AdminElectionResult, Int) raise

    Decode an ElectLeaders v2 response body.

    decode_end_txn_response

    fn decode_end_txn_response(d :
    Decoder
    ) -> (EndTxnResult, Int) raise

    Decode an EndTxn v5 response body: the error code and the identity the coordinator returns — v5 bumps the epoch on every transaction (KIP-890 part 2) and echoes the new (pid, epoch).

    decode_fetch_response

    fn decode_fetch_response(version : Int, d :
    Decoder
    ) -> (FetchResult, Int) raise

    Decode a Fetch v12-v16 response body. Tagged per-partition fields (DivergingEpoch, CurrentLeader, SnapshotId) and the tagged top-level NodeEndpoints are skipped. Returns the parsed result plus the throttle hint in milliseconds.

    decode_find_coordinator_response

    fn decode_find_coordinator_response(d :
    Decoder
    ) -> (Array[CoordinatorInfo], Int) raise

    Decode a FindCoordinator v4 response body: one entry per requested key, plus the throttle hint.

    decode_get_telemetry_subscriptions_response

    fn decode_get_telemetry_subscriptions_response(d :
    Decoder
    ) -> (TelemetrySubscription, Int) raise

    Decode a GetTelemetrySubscriptions v0 response body.

    decode_heartbeat_response

    fn decode_heartbeat_response(d :
    Decoder
    ) -> (Int, Int) raise

    Decode a Heartbeat v4 response body: just the error code.

    decode_incremental_alter_configs_response

    fn decode_incremental_alter_configs_response(d :
    Decoder
    ) -> (Array[AlterConfigsResult], Int) raise

    Decode an IncrementalAlterConfigs v1 response body.

    decode_init_producer_id_response

    fn decode_init_producer_id_response(d :
    Decoder
    ) -> (InitProducerIdResult, Int) raise

    Decode an InitProducerId v5 response body: the assigned (or bumped) producer identity plus the throttle hint.

    decode_join_group_response

    fn decode_join_group_response(d :
    Decoder
    ) -> (JoinGroupResult, Int) raise

    Decode a JoinGroup v9 response body.

    decode_leave_group_response

    fn decode_leave_group_response(d :
    Decoder
    ) -> (Int, Array[LeaveGroupMemberResult], Int) raise

    Decode a LeaveGroup v5 response body: the group-level error plus this member's per-member entry.

    decode_list_config_resources_response

    fn decode_list_config_resources_response(version : Int, d :
    Decoder
    ) -> (ListConfigResourcesResult, Int) raise

    Decode a ListConfigResources v0/v1 response body.

    decode_list_groups_response

    fn decode_list_groups_response(d :
    Decoder
    ) -> (AdminListGroupsResult, Int) raise

    Decode a ListGroups v5 response body: a top-level error plus the groups the broker listed, with their state and type names.

    decode_list_offsets_response

    fn decode_list_offsets_response(d :
    Decoder
    ) -> (Map[Int, Int64], Int) raise

    Decode a ListOffsets v10/v11 response body (the shape is unchanged since v7). Returns partition index -> offset plus the throttle hint in milliseconds.

    decode_list_partition_reassignments_response

    fn decode_list_partition_reassignments_response(d :
    Decoder
    ) -> (AdminOngoingReassignments, Int) raise

    Decode a ListPartitionReassignments v0 response body.

    decode_list_transactions_response

    fn decode_list_transactions_response(d :
    Decoder
    ) -> (AdminListTransactionsResult, Int) raise

    Decode a ListTransactions response body: a top-level error, the unknown state filters, and the transactions this broker coordinates.

    decode_metadata_response

    fn decode_metadata_response(version : Int, d :
    Decoder
    ) -> (Metadata, Int) raise

    Decode a Metadata v12 or v13 response body. v13 appends a top-level error code after the topics array. Returns the metadata plus the throttle hint in milliseconds.

    decode_offset_commit_response

    fn decode_offset_commit_response(version : Int, d :
    Decoder
    ) -> (Array[OffsetCommitPartitionResult], Int) raise

    Decode an OffsetCommit response body (same shape for v8-v10, with the topic name present through v9 and the topic id from v10): flat per-partition results plus the throttle hint.

    decode_offset_delete_response

    fn decode_offset_delete_response(d :
    Decoder
    ) -> (OffsetDeleteResult, Int) raise

    Decode an OffsetDelete v0 response body (non-flexible: no tag buffers anywhere).

    decode_offset_fetch_response

    fn decode_offset_fetch_response(version : Int, d :
    Decoder
    ) -> (Array[OffsetFetchGroupResult], Int) raise

    Decode an OffsetFetch v8/v9/v10 response body: per-group results (partitions flattened across topics) plus the throttle hint.

    decode_offset_for_leader_epoch_response

    fn decode_offset_for_leader_epoch_response(d :
    Decoder
    ) -> (Array[EpochEndOffset], Int) raise

    Decode an OffsetForLeaderEpoch v4 response body: per-partition epoch end offsets plus the throttle hint. UNDEFINED_EPOCH end offset (-1) means the broker has no data for the requested epoch.

    decode_produce_response

    fn decode_produce_response(version : Int, d :
    Decoder
    ) -> (Array[ProducePartitionResult], Int) raise

    Decode a Produce v12 or v13 response body. v13 identifies topics by id; everything else matches, including per-record errors (KIP-467). Returns the per-partition results plus the throttle hint.

    decode_push_telemetry_response

    fn decode_push_telemetry_response(d :
    Decoder
    ) -> (Int, Int) raise

    Decode a PushTelemetry v0 response body: the throttle hint plus the top-level error code.

    decode_record_batches

    fn decode_record_batches(data : Bytes) -> Array[Record] raise
    DecodeError

    Decode all record batches, ignoring any truncated trailing batch.

    decode_record_batches_detailed

    fn decode_record_batches_detailed(data : Bytes) -> (Array[DecodedBatch], Bool) raise
    DecodeError

    Decode all record batches concatenated in data (as found in a Fetch response's records field) with their batch-level metadata. Compressed batches are skipped until their codec lands; control batches decode as empty records with is_control set. truncated marks a batch the input cut short (possible when max_bytes splits a batch): it is not included in the result, so the caller's read position must not skip past it.

    decode_record_batches_ex

    fn decode_record_batches_ex(data : Bytes) -> (Array[Record], Bool) raise
    DecodeError

    Decode all record batches into flat record lists, reporting whether a truncated trailing batch was dropped (batches remain offset-safe).

    decode_sasl_authenticate_response

    fn decode_sasl_authenticate_response(d :
    Decoder
    ) -> SaslAuthenticateResult raise

    decode_sasl_handshake_response

    fn decode_sasl_handshake_response(d :
    Decoder
    ) -> SaslHandshakeResult raise

    SaslHandshake v1 response: non-flexible, so the mechanisms array uses an int32 count and int16-length strings.

    decode_share_acknowledge_response

    fn decode_share_acknowledge_response(version : Int, d :
    Decoder
    ) -> (ShareAcknowledgeResult, Int) raise

    Decode a ShareAcknowledge v1/v2 response body.

    decode_share_fetch_response

    fn decode_share_fetch_response(version : Int, d :
    Decoder
    ) -> (ShareFetchResult, Int) raise

    Decode a ShareFetch v1/v2 response body. The tagged per-partition fields and top-level NodeEndpoints are skipped; acquired ranges and records are decoded.

    decode_share_group_heartbeat_response

    fn decode_share_group_heartbeat_response(d :
    Decoder
    ) -> (ShareGroupHeartbeatResult, Int) raise

    Decode a ShareGroupHeartbeat response body.

    decode_sync_group_response

    fn decode_sync_group_response(d :
    Decoder
    ) -> (SyncGroupResult, Int) raise

    Decode a SyncGroup v5 response body.

    decode_txn_offset_commit_response

    fn decode_txn_offset_commit_response(d :
    Decoder
    ) -> (Array[TxnPartitionResult], Int) raise

    Decode a TxnOffsetCommit v4 response body: per-partition error codes plus the throttle hint.

    decode_unregister_broker_response

    fn decode_unregister_broker_response(d :
    Decoder
    ) -> (UnregisterBrokerResult, Int) raise

    Decode an UnregisterBroker v0 response body.

    decode_update_features_response

    fn decode_update_features_response(d :
    Decoder
    ) -> (AdminUpdateFeaturesResult, Int) raise

    Decode an UpdateFeatures v2 response body (v2 dropped the per-feature results array).

    driver_api_range

    fn driver_api_range(api_key : Int) -> ApiRange?

    The driver's version matrix. Grow a row's range only when codecs for the new versions exist — pick may return any version inside a row, and the encoders/decoders must be able to handle what it returns.

    encode_add_offsets_to_txn_request

    fn encode_add_offsets_to_txn_request(transactional_id : String, producer_id : Int64, producer_epoch : Int, group_id : String) -> Bytes

    Encode an AddOffsetsToTxn v4 request body: registers the consumer group whose offsets are about to be committed inside the transaction.

    encode_add_partitions_to_txn_request

    fn encode_add_partitions_to_txn_request(transactional_id : String, producer_id : Int64, producer_epoch : Int, topics : Array[(String, Array[Int])]) -> Bytes

    Encode an AddPartitionsToTxn v3 request body (client shape): the transactional id, producer identity, and the topics with the partitions being added to the ongoing transaction.

    encode_alter_client_quotas_request

    fn encode_alter_client_quotas_request(entries : Array[ClientQuotaAlteration], validate_only : Bool, version : Int) -> Bytes

    Encode an AlterClientQuotas v0-v1 request body.

    encode_alter_configs_request

    fn encode_alter_configs_request(resources : Array[SettableConfigResource], validate_only : Bool) -> Bytes

    Encode an AlterConfigs v2 request body.

    encode_alter_partition_reassignments_request

    fn encode_alter_partition_reassignments_request(topics : Array[ReassignableTopic], timeout_ms : Int, allow_replication_factor_change : Bool, version : Int) -> Bytes

    Encode an AlterPartitionReassignments v0/v1 request body.

    encode_alter_share_group_offsets_request

    fn encode_alter_share_group_offsets_request(group_id : String, topics : Array[ShareOffsetAlterTopic]) -> Bytes

    Encode an AlterShareGroupOffsets v0 request body.

    encode_alter_user_scram_request

    fn encode_alter_user_scram_request(deletions : Array[ScramCredentialDeletion], upsertions : Array[ScramCredentialUpsertion]) -> Bytes

    Encode an AlterUserScramCredentials v0 request body: deletions and upsertions, each followed by its own per-item result.

    encode_api_versions_request

    fn encode_api_versions_request() -> Bytes

    encode_consumer_group_describe_request

    fn encode_consumer_group_describe_request(group_ids : Array[String], include_authorized_operations : Bool) -> Bytes

    Encode a ConsumerGroupDescribe v1 request body (wire-identical to v0).

    encode_consumer_group_heartbeat_request

    fn encode_consumer_group_heartbeat_request(version : Int, group_id : String, member_id : String, member_epoch : Int, instance_id? : String?, rack_id? : String?, rebalance_timeout_ms? : Int, subscribed_topic_names? : Array[String]?, subscribed_topic_regex? : String?, server_assignor? : String?) -> Bytes raise

    Encode a ConsumerGroupHeartbeat request body. Optional fields the member leaves unchanged send None (the server keeps its state); the owned-partition list is sent as null (unchanged), so the server drives assignment.

    encode_consumer_protocol_assignment

    fn encode_consumer_protocol_assignment(assignment : Array[(String, Array[Int])]) -> Bytes

    Serialize a ConsumerProtocolAssignment: topic partitions per member.

    encode_consumer_protocol_subscription

    fn encode_consumer_protocol_subscription(topics : Array[String]) -> Bytes

    Serialize a ConsumerProtocolSubscription: the subscribed topic names (userData stays empty).

    encode_create_acls_request

    fn encode_create_acls_request(creations : Array[AclCreation]) -> Bytes

    Encode a CreateAcls v2/v3 request body.

    encode_create_partitions_request

    fn encode_create_partitions_request(topics : Array[CreatePartitionsSpec], timeout_ms : Int, validate_only : Bool) -> Bytes

    Encode a CreatePartitions v3 request body.

    encode_create_topics_request

    fn encode_create_topics_request(topics : Array[CreatableTopic], timeout_ms : Int, validate_only : Bool) -> Bytes

    Encode a CreateTopics v7 request body.

    encode_delete_acls_request

    fn encode_delete_acls_request(filters : Array[AclFilter]) -> Bytes

    Encode a DeleteAcls v2/v3 request body.

    encode_delete_groups_request

    fn encode_delete_groups_request(groups : Array[String]) -> Bytes

    Encode a DeleteGroups v2 request body.

    encode_delete_records_request

    fn encode_delete_records_request(topics : Array[(String, Array[(Int, Int64)])], timeout_ms : Int) -> Bytes

    Encode a DeleteRecords v2 request body: records up to (and including) each offset are deleted; OFFSET_START/-1 means "delete everything".

    encode_delete_share_group_offsets_request

    fn encode_delete_share_group_offsets_request(group_id : String, topics : Array[String]) -> Bytes

    Encode a DeleteShareGroupOffsets v0 request body.

    encode_delete_topics_request

    fn encode_delete_topics_request(names : Array[String], topic_ids : Array[Uuid], timeout_ms : Int) -> Bytes

    Encode a DeleteTopics v6 request body: topics addressed by name, by topic id, or mixed (topic-id-first addressing, KIP-516 — a null name with a set id deletes by id alone).

    encode_describe_acls_request

    fn encode_describe_acls_request(filter : AclFilter) -> Bytes

    Encode a DescribeAcls v2/v3 request body.

    encode_describe_client_quotas_request

    fn encode_describe_client_quotas_request(filter : ClientQuotaFilter, version : Int) -> Bytes

    Encode a DescribeClientQuotas v0-v1 request body.

    encode_describe_cluster_request

    fn encode_describe_cluster_request(include_cluster_authorized_operations : Bool, include_fenced_brokers : Bool, version : Int) -> Bytes

    Encode a DescribeCluster v0-v2 request body.

    encode_describe_configs_request

    fn encode_describe_configs_request(resources : Array[ConfigResourceKey]) -> Bytes

    Encode a DescribeConfigs v4 request body.

    encode_describe_groups_request

    fn encode_describe_groups_request(groups : Array[String], include_authorized_operations : Bool) -> Bytes

    Encode a DescribeGroups v6 request body.

    encode_describe_log_dirs_request

    fn encode_describe_log_dirs_request(topics : Array[(String, Array[Int])]?, version : Int) -> Bytes

    Encode a DescribeLogDirs v2-v5 request body: topics None asks for all topics (null array on the wire).

    encode_describe_producers_request

    fn encode_describe_producers_request(topics : Array[(String, Array[Int])]) -> Bytes

    Encode a DescribeProducers v0 request body: the topics and the partition indexes to list producers for.

    encode_describe_quorum_request

    fn encode_describe_quorum_request(topics : Array[(String, Array[Int])]) -> Bytes

    Encode a DescribeQuorum v2 request body.

    encode_describe_share_group_offsets_request

    fn encode_describe_share_group_offsets_request(groups : Array[ShareOffsetDescribeGroup]) -> Bytes

    Encode a DescribeShareGroupOffsets v0/v1 request body.

    encode_describe_topic_partitions_request

    fn encode_describe_topic_partitions_request(topics : Array[String], response_partition_limit : Int, cursor? : TopicPartitionCursor?) -> Bytes

    Encode a DescribeTopicPartitions v0 request body. An empty topics list describes all topics (what regex subscription expands against); cursor resumes a previous page. A nullable struct on the wire is a signed byte marker, -1 = null, 1 = present (per the Java generator).

    encode_describe_transactions_request

    fn encode_describe_transactions_request(transactional_ids : Array[String]) -> Bytes

    Encode a DescribeTransactions v0 request body: the transactional ids to describe. An empty array asks for nothing (the broker returns nothing).

    encode_describe_user_scram_request

    fn encode_describe_user_scram_request(users : Array[String]?) -> Bytes

    Encode a DescribeUserScramCredentials v0 request body: the users to describe, or None to describe every user with credentials.

    encode_elect_leaders_request

    fn encode_elect_leaders_request(election_type : Int, topic_partitions : Array[(String, Array[Int])]?, timeout_ms : Int) -> Bytes

    Encode an ElectLeaders v2 request body: topic_partitions None elects for every partition (null array on the wire).

    encode_end_txn_request

    fn encode_end_txn_request(transactional_id : String, producer_id : Int64, producer_epoch : Int, committed : Bool) -> Bytes

    Encode an EndTxn v5 request body: commit or abort the ongoing transaction.

    encode_fetch_request

    fn encode_fetch_request(version : Int, topics : Array[FetchTopicReq], session~ : FetchSessionReq, max_wait_ms~ : Int, min_bytes? : Int, max_bytes? : Int, isolation_level? : Int, rack_id? : String) -> Bytes raise

    Encode a Fetch request body for v12-v16.

    encode_find_coordinator_request

    fn encode_find_coordinator_request(keys : Array[String], coordinator_type : CoordinatorType) -> Bytes

    Encode a FindCoordinator v4 request body: the batched keys plus the coordinator type (field order per the v4 schema).

    encode_get_telemetry_subscriptions_request

    fn encode_get_telemetry_subscriptions_request(client_instance_id : Uuid) -> Bytes

    Encode a GetTelemetrySubscriptions v0 request body: the client's instance id (zero until the broker assigns one).

    encode_heartbeat_request

    fn encode_heartbeat_request(group_id : String, generation_id : Int, member_id : String, group_instance_id? : String?) -> Bytes

    Encode a Heartbeat v4 request body.

    encode_incremental_alter_configs_request

    fn encode_incremental_alter_configs_request(resources : Array[AlterableConfigResource], validate_only : Bool) -> Bytes

    Encode an IncrementalAlterConfigs v1 request body.

    encode_init_producer_id_request

    fn encode_init_producer_id_request(transactional_id : String?, transaction_timeout_ms : Int, producer_id : Int64, producer_epoch : Int) -> Bytes

    Encode an InitProducerId v5 request body. transactional_id None means a plain idempotent producer; a set pid/epoch asks the broker to bump the epoch for the existing identity.

    encode_join_group_request

    fn encode_join_group_request(group_id : String, session_timeout_ms : Int, rebalance_timeout_ms : Int, member_id : String, group_instance_id? : String?, protocols~ : Array[JoinGroupProtocol]) -> Bytes

    Encode a JoinGroup v9 request body. member_id empty joins fresh; group_instance_id enables static membership. Protocols ride the assignor names this member supports with subscription metadata.

    encode_leave_group_request

    fn encode_leave_group_request(group_id : String, member_id : String, group_instance_id? : String?) -> Bytes

    Encode a LeaveGroup v5 request body: this member (and, for static membership, the instance id) leaving the group.

    encode_list_config_resources_request

    fn encode_list_config_resources_request(resource_types : Array[Int], version : Int) -> Bytes

    Encode a ListConfigResources v0/v1 request body: v1 filters by resource type (an empty filter means all supported types).

    encode_list_groups_request

    fn encode_list_groups_request(states_filter : Array[String], types_filter : Array[String]) -> Bytes

    Encode a ListGroups v5 request body. An empty filter matches every group, so both arrays default to "no filtering".

    encode_list_offsets_request

    fn encode_list_offsets_request(version : Int, topic : String, partitions : Array[PartitionInfo], timestamp : Int64, timeout_ms? : Int) -> Bytes raise

    Encode a ListOffsets v10/v11 request body: one topic, one entry per partition. timestamp is a sentinel or a wall-clock query.

    encode_list_partition_reassignments_request

    fn encode_list_partition_reassignments_request(topics : Array[(String, Array[Int])]?, timeout_ms : Int) -> Bytes

    Encode a ListPartitionReassignments v0 request body: topics None lists every ongoing reassignment.

    encode_list_transactions_request

    fn encode_list_transactions_request(api_version : Int, state_filters : Array[String], producer_id_filters : Array[Int64], duration_filter : Int64, transactional_id_pattern : String?) -> Bytes

    Encode a ListTransactions request body. The request grows by version: v1 adds the duration filter, v2 adds the nullable transactional-id pattern, so api_version decides whether that trailing field is written.

    encode_metadata_request

    fn encode_metadata_request(topics : Array[String]?) -> Bytes

    Encode a Metadata v12/v13 request body (the request shape is identical in both versions). topics None asks for all topics; entries are addressed by name with a zero topic id.

    encode_offset_commit_request

    fn encode_offset_commit_request(version : Int, group_id : String, generation_id_or_member_epoch : Int, member_id : String, group_instance_id : String?, topics : Array[CommitTopic]) -> Bytes raise

    Encode an OffsetCommit v8/v9/v10 request body. generation_id_or_member_epoch is -1 and member_id empty for group-less commits; KIP-848 members send their epoch.

    encode_offset_delete_request

    fn encode_offset_delete_request(group_id : String, topics : Array[(String, Array[Int])]) -> Bytes

    Encode an OffsetDelete v0 request body: the committed offsets to delete for a group. v0 is not flexible — header v0 framing.

    encode_offset_fetch_request

    fn encode_offset_fetch_request(version : Int, group_id : String, member_id : String, member_epoch : Int, topics : Array[FetchOffsetTopic], require_stable? : Bool) -> Bytes raise

    Encode an OffsetFetch v8/v9/v10 request body for one group. member_id/member_epoch identify a KIP-848 member (v9+); a group-less fetch sends ""/-1.

    encode_offset_for_leader_epoch_request

    fn encode_offset_for_leader_epoch_request(topic : String, partitions : Array[(Int, Int, Int)], timeout_ms? : Int) -> Bytes

    Encode an OffsetForLeaderEpoch v4 request body: one topic, one entry per partition, asking for the last offset of leader_epoch (the consumer sends its current leader epoch for fencing).

    encode_produce_request

    fn encode_produce_request(version : Int, topic : String, topic_id : Uuid, partitions : Array[(Int, Bytes)], transactional_id? : String?, acks~ : Int, timeout_ms~ : Int) -> Bytes raise

    Encode a Produce v12/v13 request body: one topic, one record batch per partition. v12 addresses the topic by name; v13 by id (a zero topic id would mean "unknown" to the broker, so it raises). transactional_id is None for the non-transactional producer.

    encode_push_telemetry_request

    fn encode_push_telemetry_request(client_instance_id : Uuid, subscription_id : Int, terminating : Bool, compression_type : Int, metrics : Bytes) -> Bytes

    Encode a PushTelemetry v0 request body. metrics is the opaque payload rendered by the client's metrics provider.

    encode_record_batch

    fn encode_record_batch(records : Array[Record]) -> Bytes

    Encode records into a single uncompressed batch at base offset 0.

    encode_record_batch_with_base_offset

    fn encode_record_batch_with_base_offset(base_offset : Int64, records : Array[Record]) -> Bytes

    Encode records into a single RecordBatch v2 (magic = 2), uncompressed, create-time timestamps. Record offsets are rebased to sequential deltas from base_offset; timestamps are absolute ms since epoch.

    encode_request

    fn encode_request(api_key : Int, api_version : Int, correlation_id : Int, client_id : String, body : Bytes, flexible? : Bool) -> Bytes

    Encode a full request frame: INT32 size prefix + header + body. Flexible versions use header v2 (client_id as a COMPACT_NULLABLE_STRING followed by an empty tag buffer, per RequestHeader.json); the rest use header v1 with a legacy NULLABLE_STRING (SaslHandshake v1 today).

    encode_sasl_authenticate_request

    fn encode_sasl_authenticate_request(auth_bytes : Bytes) -> Bytes

    SaslAuthenticate v2 body: auth bytes as a compact byte array.

    encode_sasl_handshake_request

    fn encode_sasl_handshake_request(mechanism : String) -> Bytes

    SaslHandshake v1 body: the mechanism name as a NON-compact string.

    encode_share_acknowledge_request

    fn encode_share_acknowledge_request(version : Int, group_id : String, member_id : String, session_epoch : Int, topics : Array[ShareFetchTopic]) -> Bytes raise

    Encode a ShareAcknowledge v1/v2 request body. member_id may be empty (None on the wire) for admin-only acknowledgements on older flows; session_epoch 0 opens, -1 closes a share session.

    encode_share_fetch_request

    fn encode_share_fetch_request(version : Int, group_id : String, member_id : String, session_epoch : Int, topics : Array[ShareFetchTopic], forgotten~ : Array[ShareForgottenTopic], max_wait_ms~ : Int, min_bytes? : Int, max_bytes? : Int, max_records? : Int, batch_size? : Int) -> Bytes raise

    Encode a ShareFetch v1/v2 request body. acknowledge carries the batches to send on each partition (may be empty; the array is then a single -1 null marker). v2's tagged ShareAcquireMode/IsRenewAck stay at their defaults (batch-optimized, no renew acks).

    encode_share_group_heartbeat_request

    fn encode_share_group_heartbeat_request(version : Int, group_id : String, member_id : String, member_epoch : Int, rack_id? : String?, subscribed_topic_names? : Array[String]?) -> Bytes raise

    Encode a ShareGroupHeartbeat v1 request body. member_epoch 0 joins, -1 leaves; a positive value reconciles. Rack and subscription ride along only when they change (None keeps the broker's state).

    encode_sync_group_request

    fn encode_sync_group_request(group_id : String, generation_id : Int, member_id : String, group_instance_id? : String?, protocol_name? : String, assignments~ : Array[SyncGroupAssignment]) -> Bytes

    Encode a SyncGroup v5 request body: the leader carries every member's assignment; followers send an empty list and receive their own.

    encode_txn_offset_commit_request

    fn encode_txn_offset_commit_request(transactional_id : String, group_id : String, producer_id : Int64, producer_epoch : Int, generation_id : Int, member_id : String, topics : Array[(String, Array[TxnOffset])]) -> Bytes

    Encode a TxnOffsetCommit v4 request body: the offsets to commit for group_id as part of the transaction. v3+ carries the consumer member identity; a standalone (non-joiner) commit sends the defaults generation -1 and empty member id, like the Java client.

    encode_unregister_broker_request

    fn encode_unregister_broker_request(broker_id : Int) -> Bytes

    Encode an UnregisterBroker v0 request body.

    encode_update_features_request

    fn encode_update_features_request(updates : Array[FeatureUpdate], timeout_ms : Int, validate_only : Bool) -> Bytes

    Encode an UpdateFeatures v2 request body.

    error_name

    fn error_name(code : Int) -> String

    Protocol name for a broker error code; unknown codes render as "UNKNOWN(code)".

    error_retriable

    fn error_retriable(code : Int) -> Bool

    Whether the protocol marks the error code as retriable; unknown codes are treated as not retriable.

    render_metrics

    fn render_metrics(snapshot : Array[(String, Int64)]) -> Bytes

    Render a simple "key=value\n" text payload from a key/value snapshot — a convenient default provider body for exposing driver counters.

    scram_auth_message

    fn scram_auth_message(client_first_bare : String, server_first : String, client_final_without_proof : String) -> String

    AuthMessage = client-first-bare "," server-first "," client-final-without-proof.

    scram_client_proof_b64

    fn scram_client_proof_b64(sha512 : Bool, salted_password : Bytes, auth_message : String) -> String

    ClientProof = ClientKey XOR ClientSignature, base64-encoded.

    scram_escape_username

    fn scram_escape_username(username : String) -> String

    Escape the username per the SCRAM spec: '=' and ',' are sent as =3D and =2C. (Full SASLprep normalization is not applied; usernames made of printable ASCII are unaffected.)

    scram_pbkdf2_hmac

    fn[H :
    CryptoHasher
    ] scram_pbkdf2_hmac(h : H, password : Bytes, salt : Bytes, iterations : Int, dk_len : Int) -> Bytes

    PBKDF2-HMAC (RFC 2898) producing exactly dk_len bytes; SCRAM always uses dk_len equal to the hash output length, i.e. a single block.

    scram_salted_password

    fn scram_salted_password(sha512 : Bool, password : Bytes, salt : Bytes, iterations : Int) -> Bytes

    SaltedPassword = Hi(password, salt, iterations), i.e. PBKDF2-HMAC.

    scram_server_final

    fn scram_server_final(sha512 : Bool, salted_password : Bytes, auth_message : String) -> String

    The broker's server signature, verified against the server-final message; also used by the fake-broker tests from the server side.

    scram_server_signature_b64

    fn scram_server_signature_b64(sha512 : Bool, salted_password : Bytes, auth_message : String) -> String

    ServerSignature = HMAC(ServerKey, AuthMessage), base64-encoded; the client verifies the broker's server-final "v=" against it.

    scram_verify_client_proof

    fn scram_verify_client_proof(sha512 : Bool, salted_password : Bytes, auth_message : String, proof_b64 : String) -> Bool

    Server-side check of a client proof: recompute the stored key from the known salted password and confirm proof XOR ClientSignature hashes to it.