Skip to content

Commit d40ac19

Browse files
committedFeb 7, 2024
kgo: un-deprecate SaramaHasher and add docs explaining why
Closes #669.
1 parent a2d69ce commit d40ac19

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed
 

‎pkg/kgo/partitioner.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,16 @@ func KafkaHasher(hashFn func([]byte) uint32) PartitionerHasher {
487487
}
488488
}
489489

490-
// Deprecated: SaramaHasher is not compatible with Sarama's default partitioner
491-
// and only remains to avoid re-keying records for existing users of this API. See
492-
// [SaramaCompatHasher] for a correct partitioner.
490+
// SaramaHasher is a historical misnamed partitioner. This library's original
491+
// implementation of the SaramaHasher was incorrect, if you want an exact
492+
// match for the Sarama partitioner, use the [SaramaCompatHasher].
493+
//
494+
// This partitioner remains because as it turns out, other ecosystems provide
495+
// a similar partitioner and this partitioner is useful for compatibility.
496+
//
497+
// In particular, using this function with a crc32.ChecksumIEEE hasher makes
498+
// this partitioner match librdkafka's consistent partitioner, or the
499+
// zendesk/ruby-kafka partitioner.
493500
func SaramaHasher(hashFn func([]byte) uint32) PartitionerHasher {
494501
return func(key []byte, n int) int {
495502
p := int(hashFn(key)) % n

0 commit comments

Comments
 (0)
Please sign in to comment.