Skip to content

Commit c7dd87c

Browse files
committed
add descibeclientquotas protocol
1 parent 89c534e commit c7dd87c

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

protocol/alterclientquotas/alterclientquotas.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Entry struct {
2828

2929
type Entity struct {
3030
EntityType string `kafka:"min=v0,max=v1"`
31-
EntityName string `kafka:"min=v0,max=v1",nullable`
31+
EntityName string `kafka:"min=v0,max=v1,nullable"`
3232
}
3333

3434
type Ops struct {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package describeclientquotas
2+
3+
import "github.com/segmentio/kafka-go/protocol"
4+
5+
func init() {
6+
protocol.Register(&Request{}, &Response{})
7+
}
8+
9+
type Request struct {
10+
// We need at least one tagged field to indicate that v2+ uses "flexible"
11+
// messages.
12+
_ struct{} `kafka:"min=v2,max=v2,tag"`
13+
14+
Components []Component `kafka:"min=v0,max=v1"`
15+
Strict boolean `kafka:"min=v0,max=v1"`
16+
}
17+
18+
func (r *Request) ApiKey() protocol.ApiKey { return protocol.DescribeClientQuotas }
19+
20+
func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
21+
return cluster.Brokers[cluster.Controller], nil
22+
}
23+
24+
type Component struct {
25+
EntityType string `kafka:"min=v0,max=v1"`
26+
MatchType int8 `kafka:"min=v0,max=v1"`
27+
Match string `kafka:"min=v0,max=v1,nullable"`
28+
}
29+
30+
type Response struct {
31+
// We need at least one tagged field to indicate that v2+ uses "flexible"
32+
// messages.
33+
_ struct{} `kafka:"min=v2,max=v2,tag"`
34+
35+
ThrottleTimeMs int32 `kafka:"min=v0,max=v1"`
36+
ErrorCode int16 `kafka:"min=v0,max=v1"`
37+
ErrorMessage string `kafka:"min=v0,max=v1,nullable"`
38+
Entries []ResponseQuotas `kafka:"min=v0,max=v1"`
39+
}
40+
41+
func (r *Response) ApiKey() protocol.ApiKey { return protocol.CreateAcls }
42+
43+
type Value struct {
44+
Key string `kafka:"min=v0,max=v1"`
45+
Value float64 `kafka:"min=v0,max=v1"`
46+
}
47+
48+
type ResponseQuotas struct {
49+
Entities []Entity `kafka:"min=v0,max=v1"`
50+
Values []Value `kafka:"min=v0,max=v1"`
51+
}
52+
53+
var _ protocol.BrokerMessage = (*Request)(nil)

0 commit comments

Comments
 (0)