acl_filter.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package sarama
  2. type AclFilter struct {
  3. ResourceType AclResourceType
  4. ResourceName *string
  5. Principal *string
  6. Host *string
  7. Operation AclOperation
  8. PermissionType AclPermissionType
  9. }
  10. func (a *AclFilter) encode(pe packetEncoder) error {
  11. pe.putInt8(int8(a.ResourceType))
  12. if err := pe.putNullableString(a.ResourceName); err != nil {
  13. return err
  14. }
  15. if err := pe.putNullableString(a.Principal); err != nil {
  16. return err
  17. }
  18. if err := pe.putNullableString(a.Host); err != nil {
  19. return err
  20. }
  21. pe.putInt8(int8(a.Operation))
  22. pe.putInt8(int8(a.PermissionType))
  23. return nil
  24. }
  25. func (a *AclFilter) decode(pd packetDecoder, version int16) (err error) {
  26. resourceType, err := pd.getInt8()
  27. if err != nil {
  28. return err
  29. }
  30. a.ResourceType = AclResourceType(resourceType)
  31. if a.ResourceName, err = pd.getNullableString(); err != nil {
  32. return err
  33. }
  34. if a.Principal, err = pd.getNullableString(); err != nil {
  35. return err
  36. }
  37. if a.Host, err = pd.getNullableString(); err != nil {
  38. return err
  39. }
  40. operation, err := pd.getInt8()
  41. if err != nil {
  42. return err
  43. }
  44. a.Operation = AclOperation(operation)
  45. permissionType, err := pd.getInt8()
  46. if err != nil {
  47. return err
  48. }
  49. a.PermissionType = AclPermissionType(permissionType)
  50. return nil
  51. }