kafka::producer

Trait Partitioner

source
pub trait Partitioner {
    // Required method
    fn partition(
        &mut self,
        topics: Topics<'_>,
        msg: &mut ProduceMessage<'_, '_>,
    );
}
Expand description

A partitioner is given a chance to choose/redefine a partition for a message to be sent to Kafka. See also Record#with_partition.

Implementations can be stateful.

Required Methods§

source

fn partition(&mut self, topics: Topics<'_>, msg: &mut ProduceMessage<'_, '_>)

Supposed to inspect the given message and if desired re-assign the message’s target partition.

topics a description of the currently known topics and their currently available partitions.

msg the message whose partition assignment potentially to change.

Implementors§