partition_chooser.go 267 B

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