github.com/QuangHoangHao/kafka-go@v0.4.36/protocol/leavegroup/leavegroup.go (about) 1 package leavegroup 2 3 import "github.com/QuangHoangHao/kafka-go/protocol" 4 5 func init() { 6 protocol.Register(&Request{}, &Response{}) 7 } 8 9 type Request struct { 10 // We need at least one tagged field to indicate that this is a "flexible" message 11 // type. 12 _ struct{} `kafka:"min=v4,max=v4,tag"` 13 14 GroupID string `kafka:"min=v0,max=v2|min=v3,max=v4,compact"` 15 MemberID string `kafka:"min=v0,max=v2"` 16 Members []RequestMember `kafka:"min=v3,max=v4"` 17 } 18 19 func (r *Request) Prepare(apiVersion int16) { 20 if apiVersion < 3 { 21 if len(r.Members) > 0 { 22 r.MemberID = r.Members[0].MemberID 23 } 24 } 25 } 26 27 type RequestMember struct { 28 // We need at least one tagged field to indicate that this is a "flexible" message 29 // type. 30 _ struct{} `kafka:"min=v4,max=v4,tag"` 31 32 MemberID string `kafka:"min=v3,max=v3|min=v4,max=v4,compact"` 33 GroupInstanceID string `kafka:"min=v3,max=v3,nullable|min=v4,max=v4,nullable,compact"` 34 } 35 36 func (r *Request) ApiKey() protocol.ApiKey { return protocol.LeaveGroup } 37 38 func (r *Request) Group() string { return r.GroupID } 39 40 var ( 41 _ protocol.GroupMessage = (*Request)(nil) 42 _ protocol.PreparedMessage = (*Request)(nil) 43 ) 44 45 type Response struct { 46 // We need at least one tagged field to indicate that this is a "flexible" message 47 // type. 48 _ struct{} `kafka:"min=v4,max=v4,tag"` 49 50 ErrorCode int16 `kafka:"min=v0,max=v4"` 51 ThrottleTimeMS int32 `kafka:"min=v1,max=v4"` 52 Members []ResponseMember `kafka:"min=v3,max=v4"` 53 } 54 55 type ResponseMember struct { 56 // We need at least one tagged field to indicate that this is a "flexible" message 57 // type. 58 _ struct{} `kafka:"min=v4,max=v4,tag"` 59 60 MemberID string `kafka:"min=v3,max=v3|min=v4,max=v4,compact"` 61 GroupInstanceID string `kafka:"min=v3,max=v3,nullable|min=v4,max=v4,nullable,compact"` 62 ErrorCode int16 `kafka:"min=v3,max=v4"` 63 } 64 65 func (r *Response) ApiKey() protocol.ApiKey { return protocol.LeaveGroup }