partition_chooser.go 296 B

1234567891011121314
  1. package kafka
  2. import "math/rand"
  3. type PartitionChooser interface {
  4. ChoosePartition(key encoder, partitions []int32) int32
  5. }
  6. type RandomPartitioner struct {
  7. }
  8. func (p RandomPartitioner) ChoosePartition(key encoder, partitions []int32) int32 {
  9. return partitions[rand.Intn(len(partitions))]
  10. }