Documentation ¶
Overview ¶
Package kafka copied from https://github.com/burdiyan/kafkautil/blob/master/partitioner.go copied here to ensure this stay.
Index ¶
- func BatchesFromSlice[S any](slice []S, maxBatchSize int) [][]S
- func MapToSlice[T1 any, T2 comparable](items map[T2]T1) []T1
- func MurmurHasher() hash.Hash32
- func NewJVMCompatiblePartitioner(topic string) sarama.Partitioner
- func OrDefault[T comparable](t1, t2 T) T
- func OrDefaultSlice[T comparable](t1, t2 []T) []T
- func SliceToMap[T1 any, T2 comparable](items []T1, by func(item T1) T2) map[T2]T1
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BatchesFromSlice ¶
func MapToSlice ¶ added in v0.1.0
func MapToSlice[T1 any, T2 comparable](items map[T2]T1) []T1
func MurmurHasher ¶
MurmurHasher creates murmur2 hasher implementing hash.Hash32 interface. The implementation is not full and does not support streaming. It only implements the interface to comply with sarama.NewCustomHashPartitioner signature. But Sarama only uses Write method once, when writing keys and values of the message, so streaming support is not necessary.
func NewJVMCompatiblePartitioner ¶
func NewJVMCompatiblePartitioner(topic string) sarama.Partitioner
NewJVMCompatiblePartitioner creates a Sarama partitioner that uses the same hashing algorithm as JVM Kafka clients.
func OrDefault ¶ added in v0.1.0
func OrDefault[T comparable](t1, t2 T) T
func OrDefaultSlice ¶ added in v0.1.0
func OrDefaultSlice[T comparable](t1, t2 []T) []T
func SliceToMap ¶ added in v0.1.0
func SliceToMap[T1 any, T2 comparable](items []T1, by func(item T1) T2) map[T2]T1
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.