pub struct Fluvio { /* private fields */ }
Expand description
An interface for interacting with Fluvio streaming
Implementations§
source§impl Fluvio
impl Fluvio
sourcepub async fn connect() -> Result<Self>
pub async fn connect() -> Result<Self>
Creates a new Fluvio client using the current profile from ~/.fluvio/config
If there is no current profile or the ~/.fluvio/config
file does not exist,
then this will create a new profile with default settings and set it as
current, then try to connect to the cluster using those settings.
Example
let fluvio = Fluvio::connect().await?;
sourcepub async fn connect_with_config(config: &FluvioConfig) -> Result<Self>
pub async fn connect_with_config(config: &FluvioConfig) -> Result<Self>
Creates a new Fluvio client with the given configuration
Example
use fluvio::config::ConfigFile;
let config_file = ConfigFile::load_default_or_new()?;
let config = config_file.config().current_cluster().unwrap();
let fluvio = Fluvio::connect_with_config(&config).await?;
pub async fn connect_with_connector( connector: DomainConnector, config: &FluvioConfig ) -> Result<Self>
sourcepub async fn topic_producer<S: Into<String>>(
&self,
topic: S
) -> Result<TopicProducer>
pub async fn topic_producer<S: Into<String>>( &self, topic: S ) -> Result<TopicProducer>
Creates a new TopicProducer
for the given topic name
Currently, producers are scoped to a specific Fluvio topic. That means when you send events via a producer, you must specify which partition each event should go to.
Example
let producer = fluvio.topic_producer("my-topic").await?;
producer.send(RecordKey::NULL, "Hello, Fluvio!").await?;
sourcepub async fn topic_producer_with_config<S: Into<String>>(
&self,
topic: S,
config: TopicProducerConfig
) -> Result<TopicProducer>
pub async fn topic_producer_with_config<S: Into<String>>( &self, topic: S, config: TopicProducerConfig ) -> Result<TopicProducer>
Creates a new TopicProducer
for the given topic name
Currently, producers are scoped to a specific Fluvio topic. That means when you send events via a producer, you must specify which partition each event should go to.
Example
let config = TopicProducerConfigBuilder::default().batch_size(500).build()?;
let producer = fluvio.topic_producer_with_config("my-topic", config).await?;
producer.send(RecordKey::NULL, "Hello, Fluvio!").await?;
sourcepub async fn partition_consumer<S: Into<String>>(
&self,
topic: S,
partition: PartitionId
) -> Result<PartitionConsumer>
pub async fn partition_consumer<S: Into<String>>( &self, topic: S, partition: PartitionId ) -> Result<PartitionConsumer>
Creates a new PartitionConsumer
for the given topic and partition
If you have a topic with multiple partitions, then in order to receive
all of the events in all of the partitions, use consumer
instead.
sourcepub async fn consumer(
&self,
strategy: PartitionSelectionStrategy
) -> Result<MultiplePartitionConsumer>
pub async fn consumer( &self, strategy: PartitionSelectionStrategy ) -> Result<MultiplePartitionConsumer>
Creates a new MultiplePartitionConsumer
Currently, consumers are scoped to both a specific Fluvio topic and to a particular partition within that topic. That means that if you have a topic with multiple partitions, then in order to receive all of the events in all of the partitions, you will need to create one consumer per partition.
Records across different partitions are not guaranteed to be ordered.
Example
sourcepub async fn admin(&self) -> FluvioAdmin
pub async fn admin(&self) -> FluvioAdmin
sourcepub fn platform_version(&self) -> &Version
pub fn platform_version(&self) -> &Version
Reports the Platform Version of the connected cluster.
The “Platform Version” is the value of the VERSION file when
the cluster components were compiled, and is a semver
value.