utils

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package kafka copied from https://github.com/burdiyan/kafkautil/blob/master/partitioner.go copied here to ensure this stay.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchesFromSlice

func BatchesFromSlice[S any](slice []S, maxBatchSize int) [][]S

func MapToSlice added in v0.1.0

func MapToSlice[T1 any, T2 comparable](items map[T2]T1) []T1

func MurmurHasher

func MurmurHasher() hash.Hash32

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL