heartbeat.go 986 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package kafka
  2. import "bufio"
  3. type heartbeatRequestV0 struct {
  4. // GroupID holds the unique group identifier
  5. GroupID string
  6. // GenerationID holds the generation of the group.
  7. GenerationID int32
  8. // MemberID assigned by the group coordinator
  9. MemberID string
  10. }
  11. func (t heartbeatRequestV0) size() int32 {
  12. return sizeofString(t.GroupID) +
  13. sizeofInt32(t.GenerationID) +
  14. sizeofString(t.MemberID)
  15. }
  16. func (t heartbeatRequestV0) writeTo(wb *writeBuffer) {
  17. wb.writeString(t.GroupID)
  18. wb.writeInt32(t.GenerationID)
  19. wb.writeString(t.MemberID)
  20. }
  21. type heartbeatResponseV0 struct {
  22. // ErrorCode holds response error code
  23. ErrorCode int16
  24. }
  25. func (t heartbeatResponseV0) size() int32 {
  26. return sizeofInt16(t.ErrorCode)
  27. }
  28. func (t heartbeatResponseV0) writeTo(wb *writeBuffer) {
  29. wb.writeInt16(t.ErrorCode)
  30. }
  31. func (t *heartbeatResponseV0) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
  32. if remain, err = readInt16(r, sz, &t.ErrorCode); err != nil {
  33. return
  34. }
  35. return
  36. }