alterclientquotas.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package alterclientquotas
  2. import "github.com/segmentio/kafka-go/protocol"
  3. func init() {
  4. protocol.Register(&Request{}, &Response{})
  5. }
  6. // Detailed API definition: https://kafka.apache.org/protocol#The_Messages_AlterClientQuotas
  7. type Request struct {
  8. // We need at least one tagged field to indicate that this is a "flexible" message
  9. // type.
  10. _ struct{} `kafka:"min=v1,max=v1,tag"`
  11. Entries []Entry `kafka:"min=v0,max=v1"`
  12. ValidateOnly bool `kafka:"min=v0,max=v1"`
  13. }
  14. func (r *Request) ApiKey() protocol.ApiKey { return protocol.AlterClientQuotas }
  15. func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
  16. return cluster.Brokers[cluster.Controller], nil
  17. }
  18. type Entry struct {
  19. // We need at least one tagged field to indicate that this is a "flexible" message
  20. // type.
  21. _ struct{} `kafka:"min=v1,max=v1,tag"`
  22. Entities []Entity `kafka:"min=v0,max=v1"`
  23. Ops []Ops `kafka:"min=v0,max=v1"`
  24. }
  25. type Entity struct {
  26. // We need at least one tagged field to indicate that this is a "flexible" message
  27. // type.
  28. _ struct{} `kafka:"min=v1,max=v1,tag"`
  29. EntityType string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
  30. EntityName string `kafka:"min=v0,max=v0,nullable|min=v1,max=v1,nullable,compact"`
  31. }
  32. type Ops struct {
  33. // We need at least one tagged field to indicate that this is a "flexible" message
  34. // type.
  35. _ struct{} `kafka:"min=v1,max=v1,tag"`
  36. Key string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
  37. Value float64 `kafka:"min=v0,max=v1"`
  38. Remove bool `kafka:"min=v0,max=v1"`
  39. }
  40. type Response struct {
  41. // We need at least one tagged field to indicate that this is a "flexible" message
  42. // type.
  43. _ struct{} `kafka:"min=v1,max=v1,tag"`
  44. ThrottleTimeMs int32 `kafka:"min=v0,max=v1"`
  45. Results []ResponseQuotas `kafka:"min=v0,max=v1"`
  46. }
  47. func (r *Response) ApiKey() protocol.ApiKey { return protocol.AlterClientQuotas }
  48. type ResponseQuotas struct {
  49. // We need at least one tagged field to indicate that this is a "flexible" message
  50. // type.
  51. _ struct{} `kafka:"min=v1,max=v1,tag"`
  52. ErrorCode int16 `kafka:"min=v0,max=v1"`
  53. ErrorMessage string `kafka:"min=v0,max=v1,nullable"`
  54. Entities []Entity `kafka:"min=v0,max=v1"`
  55. }
  56. var _ protocol.BrokerMessage = (*Request)(nil)