[−][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
let consumer = fluvio::consumer("my-topic", 0).await?; let mut stream = consumer.stream(Offset::beginning()).await?; while let Ok(event) = stream.next().await { for batch in event.partition.records.batches { for record in batch.records { if let Some(record) = record.value.inner_value() { let string = String::from_utf8(record) .expect("record should be a string"); println!("Got record: {}", string); } } } }