createacls.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package createacls
  2. import "github.com/segmentio/kafka-go/protocol"
  3. func init() {
  4. protocol.Register(&Request{}, &Response{})
  5. }
  6. type Request struct {
  7. // We need at least one tagged field to indicate that v2+ uses "flexible"
  8. // messages.
  9. _ struct{} `kafka:"min=v2,max=v3,tag"`
  10. Creations []RequestACLs `kafka:"min=v0,max=v3"`
  11. }
  12. func (r *Request) ApiKey() protocol.ApiKey { return protocol.CreateAcls }
  13. func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
  14. return cluster.Brokers[cluster.Controller], nil
  15. }
  16. type RequestACLs struct {
  17. // We need at least one tagged field to indicate that v2+ uses "flexible"
  18. // messages.
  19. _ struct{} `kafka:"min=v2,max=v3,tag"`
  20. ResourceType int8 `kafka:"min=v0,max=v3"`
  21. ResourceName string `kafka:"min=v0,max=v1|min=v2,max=v3,compact"`
  22. ResourcePatternType int8 `kafka:"min=v1,max=v3"`
  23. Principal string `kafka:"min=v0,max=v1|min=v2,max=v3,compact"`
  24. Host string `kafka:"min=v0,max=v1|min=v2,max=v3,compact"`
  25. Operation int8 `kafka:"min=v0,max=v3"`
  26. PermissionType int8 `kafka:"min=v0,max=v3"`
  27. }
  28. type Response struct {
  29. // We need at least one tagged field to indicate that v2+ uses "flexible"
  30. // messages.
  31. _ struct{} `kafka:"min=v2,max=v3,tag"`
  32. ThrottleTimeMs int32 `kafka:"min=v0,max=v3"`
  33. Results []ResponseACLs `kafka:"min=v0,max=v3"`
  34. }
  35. func (r *Response) ApiKey() protocol.ApiKey { return protocol.CreateAcls }
  36. type ResponseACLs struct {
  37. // We need at least one tagged field to indicate that v2+ uses "flexible"
  38. // messages.
  39. _ struct{} `kafka:"min=v2,max=v3,tag"`
  40. ErrorCode int16 `kafka:"min=v0,max=v3"`
  41. ErrorMessage string `kafka:"min=v0,max=v1,nullable|min=v2,max=v3,nullable,compact"`
  42. }
  43. var _ protocol.BrokerMessage = (*Request)(nil)