-
Notifications
You must be signed in to change notification settings - Fork 14
/
balancer.go
48 lines (39 loc) · 916 Bytes
/
balancer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package kafka
import "github.com/segmentio/kafka-go"
type Balancer kafka.Balancer
func GetBalancerCRC32() Balancer {
return &kafka.CRC32Balancer{}
}
func GetBalancerHash() Balancer {
return &kafka.Hash{}
}
func GetBalancerLeastBytes() Balancer {
return &kafka.LeastBytes{}
}
func GetBalancerMurmur2Balancer() Balancer {
return &kafka.Murmur2Balancer{}
}
func GetBalancerReferenceHash() Balancer {
return &kafka.ReferenceHash{}
}
func GetBalancerRoundRobin() Balancer {
return &kafka.RoundRobin{}
}
func GetBalancerString(balancer Balancer) string {
switch balancer.(type) {
case *kafka.CRC32Balancer:
return "CRC32Balancer"
case *kafka.Hash:
return "Hash"
case *kafka.LeastBytes:
return "LeastBytes"
case *kafka.Murmur2Balancer:
return "Murmur2Balancer"
case *kafka.ReferenceHash:
return "ReferenceHash"
case *kafka.RoundRobin:
return "RoundRobin"
default:
return "Unknown"
}
}