Skip to content

Commit

Permalink
add more tagged fields
Browse files Browse the repository at this point in the history
  • Loading branch information
petedannemann committed May 31, 2023
1 parent 35535cf commit 5b5b590
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
22 changes: 17 additions & 5 deletions protocol/alterclientquotas/alterclientquotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,28 @@ func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
}

type Entry struct {
// We need at least one tagged field to indicate that this is a "flexible" message
// type.
_ struct{} `kafka:"min=v1,max=v1,tag"`
Entities []Entity `kafka:"min=v0,max=v1"`
Ops []Ops `kafka:"min=v0,max=v1"`
}

type Entity struct {
EntityType string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
EntityName string `kafka:"min=v0,max=v0,nullable|min=v1,max=v1,nullable,compact"`
// We need at least one tagged field to indicate that this is a "flexible" message
// type.
_ struct{} `kafka:"min=v1,max=v1,tag"`
EntityType string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
EntityName string `kafka:"min=v0,max=v0,nullable|min=v1,max=v1,nullable,compact"`
}

type Ops struct {
Key string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
Value float64 `kafka:"min=v0,max=v1"`
Remove bool `kafka:"min=v0,max=v1"`
// We need at least one tagged field to indicate that this is a "flexible" message
// type.
_ struct{} `kafka:"min=v1,max=v1,tag"`
Key string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
Value float64 `kafka:"min=v0,max=v1"`
Remove bool `kafka:"min=v0,max=v1"`
}

type Response struct {
Expand All @@ -48,6 +57,9 @@ type Response struct {
func (r *Response) ApiKey() protocol.ApiKey { return protocol.AlterClientQuotas }

type ResponseQuotas struct {
// We need at least one tagged field to indicate that this is a "flexible" message
// type.
_ struct{} `kafka:"min=v1,max=v1,tag"`
ErrorCode int16 `kafka:"min=v0,max=v1"`
ErrorMessage string `kafka:"min=v0,max=v1,nullable"`
Entities []Entity `kafka:"min=v0,max=v1"`
Expand Down
26 changes: 19 additions & 7 deletions protocol/describeclientquotas/describeclientquotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
}

type Component struct {
EntityType string `kafka:"min=v0,max=v1"`
MatchType int8 `kafka:"min=v0,max=v1"`
Match string `kafka:"min=v0,max=v1,nullable"`
// We need at least one tagged field to indicate that this is a "flexible" message
// type.
_ struct{} `kafka:"min=v1,max=v1,tag"`
EntityType string `kafka:"min=v0,max=v1"`
MatchType int8 `kafka:"min=v0,max=v1"`
Match string `kafka:"min=v0,max=v1,nullable"`
}

type Response struct {
Expand All @@ -39,16 +42,25 @@ type Response struct {
func (r *Response) ApiKey() protocol.ApiKey { return protocol.DescribeClientQuotas }

type Entity struct {
EntityType string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
EntityName string `kafka:"min=v0,max=v0,nullable|min=v1,max=v1,nullable,compact"`
// We need at least one tagged field to indicate that this is a "flexible" message
// type.
_ struct{} `kafka:"min=v1,max=v1,tag"`
EntityType string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
EntityName string `kafka:"min=v0,max=v0,nullable|min=v1,max=v1,nullable,compact"`
}

type Value struct {
Key string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
Value float64 `kafka:"min=v0,max=v1"`
// We need at least one tagged field to indicate that this is a "flexible" message
// type.
_ struct{} `kafka:"min=v1,max=v1,tag"`
Key string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
Value float64 `kafka:"min=v0,max=v1"`
}

type ResponseQuotas struct {
// We need at least one tagged field to indicate that this is a "flexible" message
// type.
_ struct{} `kafka:"min=v1,max=v1,tag"`
Entities []Entity `kafka:"min=v0,max=v1"`
Values []Value `kafka:"min=v0,max=v1"`
}
Expand Down

0 comments on commit 5b5b590

Please sign in to comment.