Trait fluvio::Partitioner

source ·
pub trait Partitioner {
    // Required method
    fn partition(
        &self,
        config: &PartitionerConfig,
        key: Option<&[u8]>,
        value: &[u8]
    ) -> PartitionId;
}
Expand description

A trait for defining a partitioning strategy for key/value records.

A Partitioner is given a slice of potential keys, and the number of partitions in the current Topic. It must map each key from the input slice into a partition stored at the same index in the output Vec.

It is up to the implementor to decide how the keys get mapped to partitions. This includes deciding what partition to assign to records with no keys (represented by None values in the keys slice).

See [SiphashRoundRobinPartitioner] for a reference implementation.

Required Methods§

source

fn partition( &self, config: &PartitionerConfig, key: Option<&[u8]>, value: &[u8] ) -> PartitionId

Implementors§