pub struct KafkaSubscriber { /* private fields */ }Expand description
A consumer-group member on one topic, yielding KafkaMessage deliveries.
Created by subscribing a KafkaTopic descriptor (or a bare topic name)
through KafkaBroker. The subscriber owns a dedicated librdkafka
consumer; dropping it closes the consumer, which leaves the group and (under auto-commit)
commits the final stored position. Under Commit::Tracked each in-flight delivery keeps
the consumer alive, so the close happens once the last outstanding message settles or
drops - do not rely on subscriber drop as an immediate group-departure barrier.
Back-pressure: polling the stream is what drives the consumer, so consuming slower simply
fetches slower; librdkafka’s own fetch queue bounds (queued.max.messages.kbytes and
friends, settable through KafkaTopic::config) cap local
buffering.
Implementations§
Trait Implementations§
Source§impl Debug for KafkaSubscriber
impl Debug for KafkaSubscriber
Source§impl Subscriber for KafkaSubscriber
impl Subscriber for KafkaSubscriber
Source§fn stream(
&mut self,
) -> impl Stream<Item = Result<Self::Message, Self::Error>> + Send + '_
fn stream( &mut self, ) -> impl Stream<Item = Result<Self::Message, Self::Error>> + Send + '_
Streams deliveries as they arrive; the stream yields an error item when the consumer fails (it does not end on its own - drop the subscriber to leave the group).
§Cancel safety
Polling is cancel safe (the underlying recv is documented cancellation safe, so no
delivery is lost by dropping the stream between polls), and the stream can be re-created
by calling stream again: deliveries buffer in the consumer, not in the returned stream.