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
(hasher func() hash.Hash32)
| 143 | // The argument is a function providing the instance, implementing the hash.Hash32 interface. This is to ensure that |
| 144 | // each partition dispatcher gets its own hasher, to avoid concurrency issues by sharing an instance. |
| 145 | func NewCustomHashPartitioner(hasher func() hash.Hash32) PartitionerConstructor { |
| 146 | return func(topic string) Partitioner { |
| 147 | p := new(hashPartitioner) |
| 148 | p.random = NewRandomPartitioner(topic) |
| 149 | p.hasher = hasher() |
| 150 | p.referenceAbs = false |
| 151 | p.hashUnsigned = false |
| 152 | return p |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | // NewCustomPartitioner creates a default Partitioner but lets you specify the behavior of each component via options |
| 157 | func NewCustomPartitioner(options ...HashPartitionerOption) PartitionerConstructor { |