heartbeat_request.go 894 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package sarama
  2. type HeartbeatRequest struct {
  3. GroupId string
  4. GenerationId int32
  5. MemberId string
  6. }
  7. func (r *HeartbeatRequest) encode(pe packetEncoder) error {
  8. if err := pe.putString(r.GroupId); err != nil {
  9. return err
  10. }
  11. pe.putInt32(r.GenerationId)
  12. if err := pe.putString(r.MemberId); err != nil {
  13. return err
  14. }
  15. return nil
  16. }
  17. func (r *HeartbeatRequest) decode(pd packetDecoder, version int16) (err error) {
  18. if r.GroupId, err = pd.getString(); err != nil {
  19. return
  20. }
  21. if r.GenerationId, err = pd.getInt32(); err != nil {
  22. return
  23. }
  24. if r.MemberId, err = pd.getString(); err != nil {
  25. return
  26. }
  27. return nil
  28. }
  29. func (r *HeartbeatRequest) key() int16 {
  30. return 12
  31. }
  32. func (r *HeartbeatRequest) version() int16 {
  33. return 0
  34. }
  35. func (r *HeartbeatRequest) headerVersion() int16 {
  36. return 1
  37. }
  38. func (r *HeartbeatRequest) requiredVersion() KafkaVersion {
  39. return V0_9_0_0
  40. }