Skip to content

Commit

Permalink
Minor changes to reflect comments to PR
Browse files Browse the repository at this point in the history
Remove type hasherFunc.
Adjust doc comments for the NewCustomHashPartitioner.
  • Loading branch information
kruftmeister committed Mar 2, 2017
1 parent f3b2363 commit 8637e89
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions partitioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,15 @@ func (p *roundRobinPartitioner) RequiresConsistency() bool {
return false
}

type hasherFunc func() hash.Hash32

type hashPartitioner struct {
random Partitioner
hasher hash.Hash32
}

// NewCustomHashPartitioner is a wrapper around NewHashPartitioner,
// allowing the use of custom hasher
func NewCustomHashPartitioner(hasher hasherFunc) PartitionerConstructor {
// NewCustomHashPartitioner is a wrapper around NewHashPartitioner, allowing the use of custom hasher.
// The argument is a function providing the instance, implementing the hash.Hash32 interface. This is to ensure that
// each partition dispatcher gets its own hasher, to avoid concurrency issues by sharing an instance.
func NewCustomHashPartitioner(hasher func() hash.Hash32) PartitionerConstructor {
return func(topic string) Partitioner {
p := new(hashPartitioner)
p.random = NewRandomPartitioner(topic)
Expand Down

0 comments on commit 8637e89

Please sign in to comment.