NewMurmur2Partitioner returns a Partitioner that replicates the partitioning behavior of the Apache Kafka Java client's DefaultPartitioner. It uses the murmur2 hash algorithm with the formula: (murmur2(keyBytes) & 0x7fffffff) % numPartitions This guarantees that a given key is always routed to th
(topic string)
| 261 | // Java producer using the default partitioner, enabling cross-language partition |
| 262 | // affinity. If the message key is nil a random partition is chosen. |
| 263 | func NewMurmur2Partitioner(topic string) Partitioner { |
| 264 | return &murmur2Partitioner{random: NewRandomPartitioner(topic)} |
| 265 | } |
| 266 | |
| 267 | func (p *murmur2Partitioner) Partition(message *ProducerMessage, numPartitions int32) (int32, error) { |
| 268 | if message.Key == nil { |