heartbeat.go 978 B

123456789101112131415161718192021222324252627282930313233343536
  1. package heartbeat
  2. import "github.com/segmentio/kafka-go/protocol"
  3. func init() {
  4. protocol.Register(&Request{}, &Response{})
  5. }
  6. // Detailed API definition: https://kafka.apache.org/protocol#The_Messages_Heartbeat
  7. type Request struct {
  8. // We need at least one tagged field to indicate that this is a "flexible" message
  9. // type.
  10. _ struct{} `kafka:"min=v4,max=v4,tag"`
  11. GroupID string `kafka:"min=v0,max=v4"`
  12. GenerationID int32 `kafka:"min=v0,max=v4"`
  13. MemberID string `kafka:"min=v0,max=v4"`
  14. GroupInstanceID string `kafka:"min=v3,max=v4,nullable"`
  15. }
  16. func (r *Request) ApiKey() protocol.ApiKey {
  17. return protocol.Heartbeat
  18. }
  19. type Response struct {
  20. // We need at least one tagged field to indicate that this is a "flexible" message
  21. // type.
  22. _ struct{} `kafka:"min=v4,max=v4,tag"`
  23. ErrorCode int16 `kafka:"min=v0,max=v4"`
  24. ThrottleTimeMs int32 `kafka:"min=v1,max=v4"`
  25. }
  26. func (r *Response) ApiKey() protocol.ApiKey {
  27. return protocol.Heartbeat
  28. }