delete_groups_response.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package sarama
  2. import (
  3. "time"
  4. )
  5. type DeleteGroupsResponse struct {
  6. ThrottleTime time.Duration
  7. GroupErrorCodes map[string]KError
  8. }
  9. func (r *DeleteGroupsResponse) encode(pe packetEncoder) error {
  10. pe.putInt32(int32(r.ThrottleTime / time.Millisecond))
  11. if err := pe.putArrayLength(len(r.GroupErrorCodes)); err != nil {
  12. return err
  13. }
  14. for groupID, errorCode := range r.GroupErrorCodes {
  15. if err := pe.putString(groupID); err != nil {
  16. return err
  17. }
  18. pe.putInt16(int16(errorCode))
  19. }
  20. return nil
  21. }
  22. func (r *DeleteGroupsResponse) decode(pd packetDecoder, version int16) error {
  23. throttleTime, err := pd.getInt32()
  24. if err != nil {
  25. return err
  26. }
  27. r.ThrottleTime = time.Duration(throttleTime) * time.Millisecond
  28. n, err := pd.getArrayLength()
  29. if err != nil {
  30. return err
  31. }
  32. if n == 0 {
  33. return nil
  34. }
  35. r.GroupErrorCodes = make(map[string]KError, n)
  36. for i := 0; i < n; i++ {
  37. groupID, err := pd.getString()
  38. if err != nil {
  39. return err
  40. }
  41. errorCode, err := pd.getInt16()
  42. if err != nil {
  43. return err
  44. }
  45. r.GroupErrorCodes[groupID] = KError(errorCode)
  46. }
  47. return nil
  48. }
  49. func (r *DeleteGroupsResponse) key() int16 {
  50. return 42
  51. }
  52. func (r *DeleteGroupsResponse) version() int16 {
  53. return 0
  54. }
  55. func (r *DeleteGroupsResponse) headerVersion() int16 {
  56. return 0
  57. }
  58. func (r *DeleteGroupsResponse) requiredVersion() KafkaVersion {
  59. return V1_1_0_0
  60. }