Skip to content

Commit

Permalink
Remove availableBroker func
Browse files Browse the repository at this point in the history
We can get the correct broker by selecting the controller
  • Loading branch information
Mongey committed Apr 14, 2019
1 parent 33f38a9 commit f517af5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
18 changes: 0 additions & 18 deletions kafka/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,3 @@ func (c *Client) topicConfig(topic string) (map[string]*string, error) {
}
return conf, nil
}

func (c *Client) availableBroker() (*sarama.Broker, error) {
var err error
brokers := *c.config.BootstrapServers
kc := c.kafkaConfig

log.Printf("[DEBUG] Looking for Brokers @ %v", brokers)
for _, b := range brokers {
broker := sarama.NewBroker(b)
err = broker.Open(kc)
if err == nil {
return broker, nil
}
log.Printf("[WARN] Broker @ %s cannot be reached\n", b)
}

return nil, fmt.Errorf("No Available Brokers @ %v", brokers)
}
7 changes: 4 additions & 3 deletions kafka/kafka_acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ func tfToAclFilter(s stringlyTypedACL) (sarama.AclFilter, error) {
}

func (c *Client) DeleteACL(s stringlyTypedACL) error {
broker, err := c.availableBroker()
broker, err := c.client.Controller()
if err != nil {
return err
}

filter, err := tfToAclFilter(s)
if err != nil {
return err
Expand All @@ -118,7 +119,7 @@ func (c *Client) DeleteACL(s stringlyTypedACL) error {
}

func (c *Client) CreateACL(s stringlyTypedACL) error {
broker, err := c.availableBroker()
broker, err := c.client.Controller()
if err != nil {
return err
}
Expand Down Expand Up @@ -210,7 +211,7 @@ func stringToAclPermissionType(in string) sarama.AclPermissionType {
}

func (c *Client) ListACLs() ([]*sarama.ResourceAcls, error) {
broker, err := c.availableBroker()
broker, err := c.client.Controller()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit f517af5

Please sign in to comment.