acl_describe_response.go 1.5 KB

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