Skip to main content

Crate kafka_meta

Crate kafka_meta 

Source
Expand description

Metadata, routing, connection pooling and the error taxonomy.

This is the layer that knows what a cluster looks like. Everything above it — admin RPCs, the read path — sends through Cluster, which resolves the right broker, retries on the errors that mean “your view is stale”, and keeps an immutable snapshot readers can take without blocking.

§The two tables

routing and the error taxonomy are first-class artifacts, each in one file, because both encode knowledge that is otherwise scattered into individual call sites and then quietly diverges.

The error table lives in kafka-connErrorCode, Error — and is re-exported here so the two sit together at the layer that acts on them. It has to be defined down there because every crate in the workspace, including the connection layer itself, needs to classify a broker’s answer, and a workspace with two error types would push a From conversion into every call site.

use kafka_meta::{Cluster, ClusterConfig};

let cluster = Cluster::connect(["localhost:9092"], ClusterConfig::default()).await?;
let snapshot = cluster.snapshot();
println!(
    "{} brokers, fetched {:?} ago",
    snapshot.brokers().len(),
    snapshot.age()
);

let leader = cluster.leader_for("orders", 0).await?;
let coordinator = cluster.coordinator_for("my-group").await?;

Structs§

BrokerInfo
A broker’s advertised endpoint.
BrokerPool
Broker connections, keyed by endpoint.
Cluster
A connected Kafka cluster: metadata, routing, connections and retries.
ClusterConfig
How to build a Cluster.
MetadataSnapshot
An immutable view of the cluster.
PartitionInfo
One partition of one topic.
RetryPolicy
How hard to retry.
TopicId
A Kafka topic id.
TopicInfo
One topic.

Enums§

ApiKey
The error taxonomy, re-exported.
BrokerSelector
How a specific broker is chosen.
CoordinatorKind
Which coordinator a request belongs to.
Endpoint
A broker to connect to.
Error
The error taxonomy, re-exported.
ErrorCode
The error taxonomy, re-exported.
Routing
Where a request has to be sent.

Constants§

KNOWN_ERROR_CODES
The error taxonomy, re-exported.

Functions§

routing
The routing class for an api key.

Type Aliases§

Result
The error taxonomy, re-exported.