kafka_client library
Experimental native Dart Kafka APIs with explicit partitions and offsets.
The core client supports plaintext or validated TLS, optional SASL PLAIN over
TLS, uncompressed magic-2 records, and read-uncommitted consumption. Explicit
partition subscriptions and manual broker-stored offsets do not join a group.
Separate experimental classic-group APIs in kafka_group.dart provide
assignment, heartbeats, processing acknowledgements and bounded managed
rejoin. They do not provide general transparent group recovery or exactly-once
processing. SCRAM, compression, idempotent production and transactions are
not implemented.
Start with KafkaClient, Broker, and KafkaRecord. Always close clients.
Advanced callers can import package:kafka_client/kafka_protocol.dart for
explicit request/response types and low-level sends.
Classes
- Broker
- Kafka TCP endpoint used for bootstrap or partition-leader routing.
- BrokerMetadata
- Represents metadata information about a Kafka broker.
- FetchPartitionResponse
- Records and log positions returned for a single partition.
- FetchResponse
- Decoded experimental Fetch v4 response with read-uncommitted records.
- FetchTopicResponse
- Fetch results for one topic.
- KafkaCancellationToken
- Cooperatively cancel a low-level send. Cancellation never logs a reason or credentials, and does not promise that an already sent Produce was undone.
- KafkaClient
- Experimental native Kafka client with validated TLS and optional PLAIN SASL. TLS is never downgraded and SASL credentials are never sent without TLS.
- KafkaCommittedOffset
- A broker-stored next position for an explicitly managed partition.
- KafkaRecord
- A binary record. Null values are tombstones, distinct from empty values.
- KafkaRecordHeader
- A record header. Duplicate keys and null values are preserved.
- KafkaSaslPlain
- SASL/PLAIN credentials, to be sent only over server-authenticated TLS.
- KafkaStableOffsetRetry
- Opt-in retry of unstable (error 88) committed offsets, requiring stable v7.
- KafkaTlsClientIdentity
- An optional client certificate identity for native mutual TLS (mTLS).
- KafkaTlsConfig
- Server-authenticated TLS settings with optional client authentication.
- KafkaTlsFetchRecovery
- Opt-in, bounded recovery from TLS-rejected or stale Fetch leaders.
- KafkaTopicRecord
- One read-uncommitted record from an explicitly selected topic partition.
- ListOffsetsPartitionResponse
- Broker result for a single partition, without interpreting errorCode.
- ListOffsetsResponse
- Immutable ListOffsets v2 results, including raw per-partition Kafka errors.
- ListOffsetsTopicResponse
- Results for one topic; the partition list is copied and immutable.
- MetadataResponse
- Represents a response to a MetadataRequest from Kafka.
- PartitionMetadata
- Represents metadata information about a partition within a Kafka topic.
- PartitionResponse
- Represents the response for a specific partition in a produce request.
- ProduceResponse
- Decoded experimental Produce v3 response for acknowledged writes.
- Record
- Backward-compatible record name; payloads are bytes, not implicit JSON.
- TopicMetadata
- Represents metadata information about a Kafka topic.
- TopicResponse
- Represents the response for a specific topic in a produce request.
Enums
- KafkaOffsetPosition
- Explicit broker position to look up without changing a consumer's position.
Exceptions / Errors
- KafkaAuthenticationException
- A sanitized authentication failure that never retains broker error text.
- KafkaBrokerException
- A broker reported a nonzero Kafka error code.
- KafkaCancelledException
- A canceled local wait. Cancellation cannot undo bytes already sent to Kafka.
- KafkaConnectionException
- A connection ended before a request could complete. Produce delivery may be ambiguous; this exception never authorizes automatic produce replay.
- KafkaOffsetCommitException
- A complete OffsetCommit response reported one or more partition errors.
- KafkaResourceLimitException
- A configured wire-resource budget was exceeded.