incremental_alter_configs_response.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package sarama
  2. import "time"
  3. // IncrementalAlterConfigsResponse is a response type for incremental alter config
  4. type IncrementalAlterConfigsResponse struct {
  5. Version int16
  6. ThrottleTime time.Duration
  7. Resources []*AlterConfigsResourceResponse
  8. }
  9. func (a *IncrementalAlterConfigsResponse) encode(pe packetEncoder) error {
  10. pe.putInt32(int32(a.ThrottleTime / time.Millisecond))
  11. if err := pe.putArrayLength(len(a.Resources)); err != nil {
  12. return err
  13. }
  14. for _, v := range a.Resources {
  15. if err := v.encode(pe); err != nil {
  16. return err
  17. }
  18. }
  19. return nil
  20. }
  21. func (a *IncrementalAlterConfigsResponse) decode(pd packetDecoder, version int16) error {
  22. throttleTime, err := pd.getInt32()
  23. if err != nil {
  24. return err
  25. }
  26. a.ThrottleTime = time.Duration(throttleTime) * time.Millisecond
  27. responseCount, err := pd.getArrayLength()
  28. if err != nil {
  29. return err
  30. }
  31. a.Resources = make([]*AlterConfigsResourceResponse, responseCount)
  32. for i := range a.Resources {
  33. a.Resources[i] = new(AlterConfigsResourceResponse)
  34. if err := a.Resources[i].decode(pd, version); err != nil {
  35. return err
  36. }
  37. }
  38. return nil
  39. }
  40. func (a *IncrementalAlterConfigsResponse) key() int16 {
  41. return 44
  42. }
  43. func (a *IncrementalAlterConfigsResponse) version() int16 {
  44. return a.Version
  45. }
  46. func (a *IncrementalAlterConfigsResponse) headerVersion() int16 {
  47. return 0
  48. }
  49. func (a *IncrementalAlterConfigsResponse) isValidVersion() bool {
  50. return a.Version == 0
  51. }
  52. func (a *IncrementalAlterConfigsResponse) requiredVersion() KafkaVersion {
  53. return V2_3_0_0
  54. }
  55. func (r *IncrementalAlterConfigsResponse) throttleTime() time.Duration {
  56. return r.ThrottleTime
  57. }