View Source KafkaEx.Producer.Partitioner.Default (kafka_ex v1.0.0-rc.1)
Default partitioner implementation.
When a message key is provided, the partition is determined using a murmur2 hash of the key. This ensures that messages with the same key always go to the same partition, providing ordering guarantees per-key.
When no message key is provided, a random partition is selected.
This implementation is compatible with the Java Kafka client's default partitioner.
Summary
Functions
Assigns a partition based on the message key.
Functions
@spec assign_partition(String.t(), binary() | nil, binary(), pos_integer()) :: non_neg_integer()
Assigns a partition based on the message key.
- If key is nil, assigns a random partition
- If key is provided, uses murmur2 hash to consistently assign to the same partition