delete_groups_response.go 1.2 KB

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