github.com/QuangHoangHao/kafka-go@v0.4.36/protocol/electleaders/electleaders.go (about) 1 package electleaders 2 3 import "github.com/QuangHoangHao/kafka-go/protocol" 4 5 func init() { 6 protocol.Register(&Request{}, &Response{}) 7 } 8 9 // Detailed API definition: https://kafka.apache.org/protocol#The_Messages_ElectLeaders 10 type Request struct { 11 ElectionType int8 `kafka:"min=v1,max=v1"` 12 TopicPartitions []RequestTopicPartitions `kafka:"min=v0,max=v1"` 13 TimeoutMs int32 `kafka:"min=v0,max=v1"` 14 } 15 16 type RequestTopicPartitions struct { 17 Topic string `kafka:"min=v0,max=v1"` 18 PartitionIDs []int32 `kafka:"min=v0,max=v1"` 19 } 20 21 func (r *Request) ApiKey() protocol.ApiKey { return protocol.ElectLeaders } 22 23 func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) { 24 return cluster.Brokers[cluster.Controller], nil 25 } 26 27 type Response struct { 28 ThrottleTime int32 `kafka:"min=v0,max=v1"` 29 ErrorCode int16 `kafka:"min=v1,max=v1"` 30 ReplicaElectionResults []ResponseReplicaElectionResult `kafka:"min=v0,max=v1"` 31 } 32 33 type ResponseReplicaElectionResult struct { 34 Topic string `kafka:"min=v0,max=v1"` 35 PartitionResults []ResponsePartitionResult `kafka:"min=v0,max=v1"` 36 } 37 38 type ResponsePartitionResult struct { 39 PartitionID int32 `kafka:"min=v0,max=v1"` 40 ErrorCode int16 `kafka:"min=v0,max=v1"` 41 ErrorMessage string `kafka:"min=v0,max=v1,nullable"` 42 } 43 44 func (r *Response) ApiKey() protocol.ApiKey { return protocol.ElectLeaders }