diff --git a/produce.go b/produce.go index 496dc3a..49dc1b7 100644 --- a/produce.go +++ b/produce.go @@ -346,16 +346,13 @@ func (cmd *produceCmd) deserializeLines(in chan string, out chan message, partit } var part int32 = 0 - if msg.Value != nil && cmd.partitioner == "hashCodeByValue" { - part = hashCodePartition(*msg.Value, partitionCount) - msg.Partition = &part - } else { - if msg.Key != nil && cmd.partitioner == "hashCode" { + if msg.Partition == nil { + if msg.Value != nil && cmd.partitioner == "hashCodeByValue" { + part = hashCodePartition(*msg.Value, partitionCount) + } else if msg.Key != nil && cmd.partitioner == "hashCode" { part = hashCodePartition(*msg.Key, partitionCount) } - if msg.Partition == nil { - msg.Partition = &part - } + msg.Partition = &part } out <- msg