alter_configs_response.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package sarama
  2. import "time"
  3. type AlterConfigsResponse struct {
  4. ThrottleTime time.Duration
  5. Resources []*AlterConfigsResourceResponse
  6. }
  7. type AlterConfigsResourceResponse struct {
  8. ErrorCode int16
  9. ErrorMsg string
  10. Type ConfigResourceType
  11. Name string
  12. }
  13. func (ct *AlterConfigsResponse) encode(pe packetEncoder) error {
  14. pe.putInt32(int32(ct.ThrottleTime / time.Millisecond))
  15. if err := pe.putArrayLength(len(ct.Resources)); err != nil {
  16. return err
  17. }
  18. for i := range ct.Resources {
  19. pe.putInt16(ct.Resources[i].ErrorCode)
  20. err := pe.putString(ct.Resources[i].ErrorMsg)
  21. if err != nil {
  22. return nil
  23. }
  24. pe.putInt8(int8(ct.Resources[i].Type))
  25. err = pe.putString(ct.Resources[i].Name)
  26. if err != nil {
  27. return nil
  28. }
  29. }
  30. return nil
  31. }
  32. func (acr *AlterConfigsResponse) decode(pd packetDecoder, version int16) error {
  33. throttleTime, err := pd.getInt32()
  34. if err != nil {
  35. return err
  36. }
  37. acr.ThrottleTime = time.Duration(throttleTime) * time.Millisecond
  38. responseCount, err := pd.getArrayLength()
  39. if err != nil {
  40. return err
  41. }
  42. acr.Resources = make([]*AlterConfigsResourceResponse, responseCount)
  43. for i := range acr.Resources {
  44. acr.Resources[i] = new(AlterConfigsResourceResponse)
  45. errCode, err := pd.getInt16()
  46. if err != nil {
  47. return err
  48. }
  49. acr.Resources[i].ErrorCode = errCode
  50. e, err := pd.getString()
  51. if err != nil {
  52. return err
  53. }
  54. acr.Resources[i].ErrorMsg = e
  55. t, err := pd.getInt8()
  56. if err != nil {
  57. return err
  58. }
  59. acr.Resources[i].Type = ConfigResourceType(t)
  60. name, err := pd.getString()
  61. if err != nil {
  62. return err
  63. }
  64. acr.Resources[i].Name = name
  65. }
  66. return nil
  67. }
  68. func (r *AlterConfigsResponse) key() int16 {
  69. return 32
  70. }
  71. func (r *AlterConfigsResponse) version() int16 {
  72. return 0
  73. }
  74. func (r *AlterConfigsResponse) requiredVersion() KafkaVersion {
  75. return V0_11_0_0
  76. }