pub struct Client { /* private fields */ }Expand description
A Kafka client backed by a BrokerPool.
Construct via Client::builder.
Cloning a Client is cheap — it shares the underlying BrokerPool via
an Arc and the connection options via a value clone.
Implementations§
Source§impl Client
impl Client
Source§impl Client
impl Client
Sourcepub async fn send<R: ProtocolRequest>(
&self,
req: R,
) -> Result<R::Response, ClientError>
pub async fn send<R: ProtocolRequest>( &self, req: R, ) -> Result<R::Response, ClientError>
Send a request to the bootstrap broker (or any cached open connection).
Sourcepub fn knows_broker(&self, broker_id: i32) -> bool
pub fn knows_broker(&self, broker_id: i32) -> bool
Whether the pool knows a dialable address for broker_id (learned via
refresh_metadata, port not 0). Lets a
caller choose between broker routing and the
bootstrap send without a speculative connect.
Sourcepub fn broker(&self, broker_id: i32) -> BrokerHandle<'_>
pub fn broker(&self, broker_id: i32) -> BrokerHandle<'_>
Return a BrokerHandle that routes requests to a specific broker by id.
The broker must have been registered via refresh_metadata first.
Sourcepub async fn refresh_metadata(&self) -> Result<MetadataResponse, ClientError>
pub async fn refresh_metadata(&self) -> Result<MetadataResponse, ClientError>
Send a default MetadataRequest, parse the broker list from the response,
refresh the pool’s address registry, and return the typed response.
Sourcepub async fn offset_for_leader_epoch(
&self,
topic: &str,
partition: i32,
current_leader_epoch: i32,
leader_epoch: i32,
) -> Result<EpochEndOffset, ClientError>
pub async fn offset_for_leader_epoch( &self, topic: &str, partition: i32, current_leader_epoch: i32, leader_epoch: i32, ) -> Result<EpochEndOffset, ClientError>
Send a single-partition OffsetForLeaderEpoch (api_key=23) via the
bootstrap connection. Thin wrapper over the free
offset_for_leader_epoch helper used
by the consumer’s KIP-320 position-validation pass; Client does not
otherwise expose its connection, so this borrows the same bootstrap
connection send uses.
§Errors
Transport / version-negotiation failure, or a partition not present in the response.
Sourcepub async fn offset_for_leader_epoch_on(
&self,
broker_id: i32,
topic: &str,
partition: i32,
current_leader_epoch: i32,
leader_epoch: i32,
) -> Result<EpochEndOffset, ClientError>
pub async fn offset_for_leader_epoch_on( &self, broker_id: i32, topic: &str, partition: i32, current_leader_epoch: i32, leader_epoch: i32, ) -> Result<EpochEndOffset, ClientError>
Send a single-partition OffsetForLeaderEpoch (api_key=23) to a
specific broker by id, via BrokerPool::get. Mirrors
offset_for_leader_epoch but targets
the partition leader instead of the bootstrap connection — KIP-320
requires the validation RPC reach the partition leader, which is the
only replica with the authoritative epoch→end-offset history.
The broker must already be in the pool’s registry (populated by
refresh_metadata).
§Errors
Disconnected if broker_id is not in the registry; transport /
version-negotiation failure; or a partition not present in the response.