acl_create_request.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package sarama
  2. type CreateAclsRequest struct {
  3. AclCreations []*AclCreation
  4. }
  5. func (c *CreateAclsRequest) encode(pe packetEncoder) error {
  6. if err := pe.putArrayLength(len(c.AclCreations)); err != nil {
  7. return err
  8. }
  9. for _, aclCreation := range c.AclCreations {
  10. if err := aclCreation.encode(pe); err != nil {
  11. return err
  12. }
  13. }
  14. return nil
  15. }
  16. func (c *CreateAclsRequest) decode(pd packetDecoder, version int16) (err error) {
  17. n, err := pd.getArrayLength()
  18. if err != nil {
  19. return err
  20. }
  21. c.AclCreations = make([]*AclCreation, n)
  22. for i := 0; i < n; i++ {
  23. c.AclCreations[i] = new(AclCreation)
  24. if err := c.AclCreations[i].decode(pd, version); err != nil {
  25. return err
  26. }
  27. }
  28. return nil
  29. }
  30. func (d *CreateAclsRequest) key() int16 {
  31. return 30
  32. }
  33. func (d *CreateAclsRequest) version() int16 {
  34. return 0
  35. }
  36. func (d *CreateAclsRequest) requiredVersion() KafkaVersion {
  37. return V0_11_0_0
  38. }
  39. type AclCreation struct {
  40. Resource
  41. Acl
  42. }
  43. func (a *AclCreation) encode(pe packetEncoder) error {
  44. if err := a.Resource.encode(pe); err != nil {
  45. return err
  46. }
  47. if err := a.Acl.encode(pe); err != nil {
  48. return err
  49. }
  50. return nil
  51. }
  52. func (a *AclCreation) decode(pd packetDecoder, version int16) (err error) {
  53. if err := a.Resource.decode(pd, version); err != nil {
  54. return err
  55. }
  56. if err := a.Acl.decode(pd, version); err != nil {
  57. return err
  58. }
  59. return nil
  60. }