Use all configured NATS addresses

This commit is contained in:
Till Faelligen 2021-07-04 22:11:00 +02:00
parent c575f5501f
commit 0c88ac6158

View file

@ -1,6 +1,7 @@
package kafka package kafka
import ( import (
"strings"
"time" "time"
js "github.com/S7evinK/saramajetstream" js "github.com/S7evinK/saramajetstream"
@ -66,7 +67,7 @@ func setupNaffka(cfg *config.Kafka) (sarama.Consumer, sarama.SyncProducer) {
func setupNATS(cfg *config.Kafka) (sarama.Consumer, sarama.SyncProducer) { func setupNATS(cfg *config.Kafka) (sarama.Consumer, sarama.SyncProducer) {
logrus.WithField("servers", cfg.Addresses).Debug("connecting to nats") logrus.WithField("servers", cfg.Addresses).Debug("connecting to nats")
nc, err := nats.Connect(cfg.Addresses[0]) nc, err := nats.Connect(strings.Join(cfg.Addresses, ","))
if err != nil { if err != nil {
logrus.WithError(err).Panic("failed to connect to nats") logrus.WithError(err).Panic("failed to connect to nats")
return nil, nil return nil, nil