joingroup.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package joingroup
  2. import "github.com/segmentio/kafka-go/protocol"
  3. func init() {
  4. protocol.Register(&Request{}, &Response{})
  5. }
  6. type Request struct {
  7. // We need at least one tagged field to indicate that this is a "flexible" message
  8. // type.
  9. _ struct{} `kafka:"min=v6,max=v7,tag"`
  10. GroupID string `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  11. SessionTimeoutMS int32 `kafka:"min=v0,max=v7"`
  12. RebalanceTimeoutMS int32 `kafka:"min=v1,max=v7"`
  13. MemberID string `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  14. GroupInstanceID string `kafka:"min=v5,max=v5,nullable|min=v6,max=v7,compact,nullable"`
  15. ProtocolType string `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  16. Protocols []RequestProtocol `kafka:"min=v0,max=v7"`
  17. }
  18. type RequestProtocol struct {
  19. // We need at least one tagged field to indicate that this is a "flexible" message
  20. // type.
  21. _ struct{} `kafka:"min=v6,max=v7,tag"`
  22. Name string `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  23. Metadata []byte `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  24. }
  25. func (r *Request) ApiKey() protocol.ApiKey {
  26. return protocol.JoinGroup
  27. }
  28. func (r *Request) Group() string { return r.GroupID }
  29. var _ protocol.GroupMessage = (*Request)(nil)
  30. type Response struct {
  31. // We need at least one tagged field to indicate that this is a "flexible" message
  32. // type.
  33. _ struct{} `kafka:"min=v6,max=v7,tag"`
  34. ThrottleTimeMS int32 `kafka:"min=v2,max=v7"`
  35. ErrorCode int16 `kafka:"min=v0,max=v7"`
  36. GenerationID int32 `kafka:"min=v0,max=v7"`
  37. ProtocolType string `kafka:"min=v7,max=v7,compact,nullable"`
  38. ProtocolName string `kafka:"min=v0,max=v5|min=v6,max=v6,compact|min=v7,max=v7,compact,nullable"`
  39. LeaderID string `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  40. MemberID string `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  41. Members []ResponseMember `kafka:"min=v0,max=v7"`
  42. }
  43. type ResponseMember struct {
  44. // We need at least one tagged field to indicate that this is a "flexible" message
  45. // type.
  46. _ struct{} `kafka:"min=v6,max=v7,tag"`
  47. MemberID string `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  48. GroupInstanceID string `kafka:"min=v5,max=v5,nullable|min=v6,max=v7,nullable,compact"`
  49. Metadata []byte `kafka:"min=v0,max=v5|min=v6,max=v7,compact"`
  50. }
  51. type ResponseMemberMetadata struct{}
  52. func (r *Response) ApiKey() protocol.ApiKey { return protocol.JoinGroup }