pub async fn consumer<S: Into<String>>(
topic: S,
partition: i32
) -> Result<PartitionConsumer, FluvioError>
Expand description
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 {
let key = record.key().map(|key| String::from_utf8_lossy(key).to_string());
let value = String::from_utf8_lossy(record.value()).to_string();
println!("Got record: key={:?}, value={}", key, value);
}