Skip to content

Commit

Permalink
ProducerMessage keys and values are in byte slices, so for the key (t…
Browse files Browse the repository at this point in the history
…he partition), use all the slices otherwise the max we can go is 127 for partition number
  • Loading branch information
Pablo Fischer committed Nov 25, 2015
1 parent bf804fa commit d19056c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ func (this *FixedPartitioner) Partition(key []byte, numPartitions int32) (int32,
if key == nil {
panic("FixedPartitioner does not work without keys.")
}
partition, err := binary.ReadUvarint(bytes.NewBuffer(key))
if err != nil {
return -1, err

var partition int32
buf := bytes.NewBuffer(key)
binary.Read(buf, binary.LittleEndian, &partition)
if (partition < 0) {
return -1, errors.New("Partition turned to be -1 (too big to be int32 little endian?)")
}

return int32(partition) % numPartitions, nil
Expand Down

0 comments on commit d19056c

Please sign in to comment.