Add endpoint option for sasl

This commit is contained in:
Benjamin Ramser 2021-07-08 12:05:16 +02:00 committed by tidwall
parent 55e503c378
commit e4b03ca174
2 changed files with 6 additions and 1 deletions

View File

@ -66,6 +66,7 @@ type Endpoint struct {
Host string
Port int
TopicName string
SASL bool
TLS bool
CACertFile string
CertFile string
@ -423,6 +424,8 @@ func parseEndpoint(s string) (Endpoint, error) {
endpoint.Kafka.CertFile = val[0]
case "key":
endpoint.Kafka.KeyFile = val[0]
case "sasl":
endpoint.Kafka.SASL, _ = strconv.ParseBool(val[0])
}
}
}

View File

@ -76,7 +76,9 @@ func (conn *KafkaConn) Send(msg string) error {
}
cfg.Net.TLS.Enable = true
cfg.Net.TLS.Config = tlsConfig
} else {
}
if conn.ep.Kafka.SASL {
log.Debugf("building kafka sasl config")
cfg.ClientID = "sasl_scram_client"
cfg.Net.SASL.Enable = true