twmb / franz-go

franz-go contains a feature complete, pure Go library for interacting with Kafka from 0.8.0 through 3.6+. Producing, consuming, transacting, administrating, etc.
BSD 3-Clause "New" or "Revised" License
1.6k stars 158 forks source link

Incorrect documentation regarding sarama partitioner compatibility SaramaCompatHasher #764

Open asg0451 opened 3 weeks ago

asg0451 commented 3 weeks ago

This suggestion is incorrect and does not compile: https://github.com/twmb/franz-go/blob/v1.17.0/pkg/kgo/partitioner.go#L529 Perhaps something like this was meant:

    hasher := fnv.New32a()
     kgo.StickyKeyPartitioner(kgo.SaramaCompatHasher(func(bs []byte) uint32 {
            hasher.Reset()
            _, _ = hasher.Write(bs)
            return hasher.Sum32()
        }))
twmb commented 3 weeks ago

Feel free to submit a PR, this really was meant to be more pseudocode but I'm fine if we want to make this 100% correct.

asg0451 commented 3 weeks ago

Gotcha. Can you confirm that what I wrote is correct? If so I'll submit a pr. thx

asg0451 commented 3 weeks ago

(or i can just add .. something like.. in the comment ;)

twmb commented 1 week ago

Open to anything; if you're able to test the code and then mirror that into a doc line, I'll +1 a PR. Or, if you'd prefer "something like", I'll +1 that too.