Function fluvio::producer[][src]

pub async fn producer<S: Into<String>>(
    topic: S
) -> Result<TopicProducer, FluvioError>

Creates a producer that sends records to the named topic

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: Simple records

Fluvio can send “simple” records that contain arbitrary binary data. An easy way to demonstrate this is by sending a string:

let producer = fluvio::producer("my-topic").await?;
producer.send_record("Hello, world!", 0).await?;

Example: Key-value records

Fluvio also supports “key-value” records, where the key and the value given may each be any binary data. Typically, the key represents some unique property of the value, such as an email address, username, or request ID.

let producer = fluvio::producer("my-topic").await?;
let key = "fluvio";
let value = r#"
{"project":"fluvio","about":"Data streaming in Rust!"}
producer.send(key, value).await?;