MCPcopy
hub / github.com/segmentio/kafka-go / Balancer

Interface Balancer

balancer.go:17–26  ·  balancer.go::Balancer

The Balancer interface provides an abstraction of the message distribution logic used by Writer instances to route messages to the partitions available on a kafka cluster. Balancers must be safe to use concurrently from multiple goroutines.

Source from the content-addressed store, hash-verified

15//
16// Balancers must be safe to use concurrently from multiple goroutines.
17type Balancer interface {
18 // Balance receives a message and a set of available partitions and
19 // returns the partition number that the message should be routed to.
20 //
21 // An application should refrain from using a balancer to manage multiple
22 // sets of partitions (from different topics for examples), use one balancer
23 // instance for each partition set, so the balancer can detect when the
24 // partitions change and assume that the kafka topic has been rebalanced.
25 Balance(msg Message, partitions ...int) (partition int)
26}
27
28// BalancerFunc is an implementation of the Balancer interface that makes it
29// possible to use regular functions to distribute messages across partitions.

Callers 5

BalanceMethod · 0.65
BalanceMethod · 0.65
BalanceMethod · 0.65
BalanceMethod · 0.65
WriteMessagesMethod · 0.65

Implementers 8

RoundRobinbalancer.go
LeastBytesbalancer.go
Hashbalancer.go
ReferenceHashbalancer.go
randomBalancerbalancer.go
CRC32Balancerbalancer.go
Murmur2Balancerbalancer.go
staticBalancerwriter_test.go

Calls

no outgoing calls

Tested by

no test coverage detected