Skip to content

Commit

Permalink
moved samara config out of init into connect (influxdata#9051)
Browse files Browse the repository at this point in the history
  • Loading branch information
helenosheaa authored Mar 25, 2021
1 parent f26084a commit 5653362
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions plugins/outputs/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Kafka struct {

Log telegraf.Logger `toml:"-"`

saramaConfig *sarama.Config
producerFunc func(addrs []string, config *sarama.Config) (sarama.SyncProducer, error)
producer sarama.SyncProducer

Expand Down Expand Up @@ -278,22 +279,24 @@ func (k *Kafka) Init() error {
return err
}

k.saramaConfig = config

// Legacy support ssl config
if k.Certificate != "" {
k.TLSCert = k.Certificate
k.TLSCA = k.CA
k.TLSKey = k.Key
}

producer, err := k.producerFunc(k.Brokers, config)
if err != nil {
return err
}
k.producer = producer
return nil
}

func (k *Kafka) Connect() error {
producer, err := k.producerFunc(k.Brokers, k.saramaConfig)
if err != nil {
return err
}
k.producer = producer
return nil
}

Expand Down

0 comments on commit 5653362

Please sign in to comment.