[][src]Function fluvio::consumer

pub async fn consumer<S: Into<String>>(
    topic: S,
    partition: i32
) -> Result<PartitionConsumer, FluvioError>

Creates a producer that receives events from the given topic and partition

This is a shortcut function that uses the current profile settings. If you need to specify any custom configurations, try directly creating a Fluvio client object instead.

Example

use futures::StreamExt;
let consumer = fluvio::consumer("my-topic", 0).await?;
let mut stream = consumer.stream(Offset::beginning()).await?;
while let Some(Ok(record)) = stream.next().await {
    if let Some(bytes) = record.try_into_bytes() {
        let string = String::from_utf8_lossy(&bytes);
        println!("Got record: {}", string);
    }
}