forked from segmentio/kafka-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
electleaders.go
44 lines (34 loc) · 1.46 KB
/
electleaders.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
package electleaders
import "github.com/segmentio/kafka-go/protocol"
func init() {
protocol.Register(&Request{}, &Response{})
}
// Detailed API definition: https://kafka.apache.org/protocol#The_Messages_ElectLeaders
type Request struct {
ElectionType int8 `kafka:"min=v1,max=v1"`
TopicPartitions []RequestTopicPartitions `kafka:"min=v0,max=v1"`
TimeoutMs int32 `kafka:"min=v0,max=v1"`
}
type RequestTopicPartitions struct {
Topic string `kafka:"min=v0,max=v1"`
PartitionIDs []int32 `kafka:"min=v0,max=v1"`
}
func (r *Request) ApiKey() protocol.ApiKey { return protocol.ElectLeaders }
func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
return cluster.Brokers[cluster.Controller], nil
}
type Response struct {
ThrottleTime int32 `kafka:"min=v0,max=v1"`
ErrorCode int16 `kafka:"min=v1,max=v1"`
ReplicaElectionResults []ResponseReplicaElectionResult `kafka:"min=v0,max=v1"`
}
type ResponseReplicaElectionResult struct {
Topic string `kafka:"min=v0,max=v1"`
PartitionResults []ResponsePartitionResult `kafka:"min=v0,max=v1"`
}
type ResponsePartitionResult struct {
PartitionID int32 `kafka:"min=v0,max=v1"`
ErrorCode int16 `kafka:"min=v0,max=v1"`
ErrorMessage string `kafka:"min=v0,max=v1,nullable"`
}
func (r *Response) ApiKey() protocol.ApiKey { return protocol.ElectLeaders }