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-conn — ErrorCode, 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§
- Broker
Info - A broker’s advertised endpoint.
- Broker
Pool - Broker connections, keyed by endpoint.
- Cluster
- A connected Kafka cluster: metadata, routing, connections and retries.
- Cluster
Config - How to build a
Cluster. - Metadata
Snapshot - An immutable view of the cluster.
- Partition
Info - One partition of one topic.
- Retry
Policy - How hard to retry.
- TopicId
- A Kafka topic id.
- Topic
Info - One topic.
Enums§
- ApiKey
- The error taxonomy, re-exported.
- Broker
Selector - How a specific broker is chosen.
- Coordinator
Kind - Which coordinator a request belongs to.
- Endpoint
- A broker to connect to.
- Error
- The error taxonomy, re-exported.
- Error
Code - 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.