Partitioner is anything that, given a Kafka message and a number of partitions indexed [0...numPartitions-1], decides to which partition to send the message. RandomPartitioner, RoundRobinPartitioner and HashPartitioner are provided as simple default implementations.
| 12 | // decides to which partition to send the message. RandomPartitioner, RoundRobinPartitioner and HashPartitioner are provided |
| 13 | // as simple default implementations. |
| 14 | type Partitioner interface { |
| 15 | // Partition takes a message and partition count and chooses a partition |
| 16 | Partition(message *ProducerMessage, numPartitions int32) (int32, error) |
| 17 | |
| 18 | // RequiresConsistency indicates to the user of the partitioner whether the |
| 19 | // mapping of key->partition is consistent or not. Specifically, if a |
| 20 | // partitioner requires consistency then it must be allowed to choose from all |
| 21 | // partitions (even ones known to be unavailable), and its choice must be |
| 22 | // respected by the caller. The obvious example is the HashPartitioner. |
| 23 | RequiresConsistency() bool |
| 24 | } |
| 25 | |
| 26 | // DynamicConsistencyPartitioner can optionally be implemented by Partitioners |
| 27 | // in order to allow more flexibility than is originally allowed by the |
no outgoing calls
no test coverage detected