Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix request to change broker config #1205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion protocol/alterconfigs/alterconfigs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package alterconfigs

import "github.com/segmentio/kafka-go/protocol"
import (
"strconv"

"github.com/segmentio/kafka-go/protocol"
)

const (
resourceTypeBroker int8 = 4
)

func init() {
protocol.Register(&Request{}, &Response{})
Expand All @@ -15,6 +23,18 @@ type Request struct {
func (r *Request) ApiKey() protocol.ApiKey { return protocol.AlterConfigs }

func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
// Broker alter config requests must be sent to the associated broker
for _, resource := range r.Resources {
if resource.ResourceType == resourceTypeBroker {
brokerID, err := strconv.Atoi(resource.ResourceName)
if err != nil {
return protocol.Broker{}, err
}

return cluster.Brokers[int32(brokerID)], nil
}
}

return cluster.Brokers[cluster.Controller], nil
}

Expand Down