Struct rdkafka::consumer::stream_consumer::StreamConsumer[][src]

#[must_use = "Consumer polling thread will stop immediately if unused"]pub struct StreamConsumer<C = DefaultConsumerContext, R = DefaultRuntime> where
    C: ConsumerContext
{ /* fields omitted */ }

A high-level consumer with a Stream interface.

This consumer doesn’t need to be polled explicitly. Extracting an item from the stream returned by the stream will implicitly poll the underlying Kafka consumer.

If you activate the consumer group protocol by calling subscribe, the stream consumer will integrate with librdkafka’s liveness detection as described in KIP-62. You must be sure that you attempt to extract a message from the stream consumer at least every max.poll.interval.ms milliseconds, or librdkafka will assume that the processing thread is wedged and leave the consumer groups.

Implementations

impl<C, R> StreamConsumer<C, R> where
    C: ConsumerContext + 'static, 
[src]

pub fn stream(&self) -> MessageStream<'_, C, R>[src]

Constructs a stream that yields messages from this consumer.

It is legal to have multiple live message streams for the same consumer, and to move those message streams across threads. Note, however, that the message streams share the same underlying state. A message received by the consumer will be delivered to only one of the live message streams. If you seek the underlying consumer, all message streams created from the consumer will begin to draw messages from the new position of the consumer.

If you want multiple independent views of a Kafka topic, create multiple consumers, not multiple message streams.

pub fn start(&self) -> MessageStream<'_, C, R>[src]

👎 Deprecated:

use the more clearly named “StreamConsumer::stream” method instead

Constructs a stream that yields messages from this consumer.

pub async fn recv(&self) -> Result<BorrowedMessage<'_>, KafkaError>[src]

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.

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;

consumer.stream().next().await.expect("MessageStream never returns None");

Trait Implementations

impl<C, R> Consumer<StreamConsumerContext<C>> for StreamConsumer<C, R> where
    C: ConsumerContext
[src]

impl<R> FromClientConfig for StreamConsumer<DefaultConsumerContext, R> where
    R: AsyncRuntime
[src]

impl<C, R> FromClientConfigAndContext<C> for StreamConsumer<C, R> where
    C: ConsumerContext + 'static,
    R: AsyncRuntime
[src]

Creates a new StreamConsumer starting from a ClientConfig.

Auto Trait Implementations

impl<C = DefaultConsumerContext, R = TokioRuntime> !RefUnwindSafe for StreamConsumer<C, R>

impl<C, R> Send for StreamConsumer<C, R> where
    R: Send

impl<C, R> Sync for StreamConsumer<C, R> where
    R: Sync

impl<C, R> Unpin for StreamConsumer<C, R> where
    R: Unpin

impl<C = DefaultConsumerContext, R = TokioRuntime> !UnwindSafe for StreamConsumer<C, R>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.