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.
| 15 | // |
| 16 | // Balancers must be safe to use concurrently from multiple goroutines. |
| 17 | type 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. |
no outgoing calls
no test coverage detected