Struct rdkafka::consumer::stream_consumer::StreamPartitionQueue
source · pub struct StreamPartitionQueue<C, R = DefaultRuntime>where
C: ConsumerContext + 'static,{ /* private fields */ }
Expand description
A message queue for a single partition of a StreamConsumer
.
See the documentation of StreamConsumer::split_partition_queue
for
details.
Implementations§
source§impl<C, R> StreamPartitionQueue<C, R>where
C: ConsumerContext,
impl<C, R> StreamPartitionQueue<C, R>where
C: ConsumerContext,
sourcepub fn stream(&self) -> MessageStream<'_>
pub fn stream(&self) -> MessageStream<'_>
Constructs a stream that yields messages from this partition.
It is legal to have multiple live message streams for the same partition, and to move those message streams across threads. Note, however, that the message streams share the same underlying state. A message received by the partition will be delivered to only one of the live message streams. If you seek the underlying partition, all message streams created from the partition will begin to draw messages from the new position of the partition.
If you want multiple independent views of a Kafka partition, create multiple consumers, not multiple partition streams.
sourcepub async fn recv(&self) -> Result<BorrowedMessage<'_>, KafkaError>
pub async fn recv(&self) -> Result<BorrowedMessage<'_>, KafkaError>
Receives the next message from the stream.
This method will block until the next message is available or an error
occurs. It is legal to call recv
from multiple threads simultaneously.
This method is cancellation safe.
Note that this method is exactly as efficient as constructing a single-use message stream and extracting one message from it:
use futures::stream::StreamExt;
partition_queue.stream().next().await.expect("MessageStream never returns None");