github.com/segmentio/kafka-go@v0.4.48-0.20240318174348-3f6244eb34fd/protocol/alterclientquotas/alterclientquotas.go (about)

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