partitioner.go 259 B

1234567891011121314
  1. package kafka
  2. import "math/rand"
  3. type Partitioner interface {
  4. Partition(key Encoder, numPartitions int) int
  5. }
  6. type RandomPartitioner struct {
  7. }
  8. func (p RandomPartitioner) Partition(key Encoder, numPartitions int) int {
  9. return rand.Intn(numPartitions)
  10. }