Add missing error check

Keep typing events for at least one minute
This commit is contained in:
Till Faelligen 2021-06-04 20:23:25 +02:00
parent c0c0b03c52
commit f7cfa24027

View file

@ -91,9 +91,9 @@ func setupNATS(cfg *config.Kafka) (sarama.Consumer, sarama.SyncProducer) {
// Typing events can be removed from the stream, as they are only relevant for a short time // Typing events can be removed from the stream, as they are only relevant for a short time
if topic == config.TopicOutputTypingEvent { if topic == config.TopicOutputTypingEvent {
maxLifeTime = time.Second * 30 maxLifeTime = time.Second * 60
} }
_, _ = s.AddStream(&nats.StreamConfig{ _, err = s.AddStream(&nats.StreamConfig{
Name: sn, Name: sn,
Subjects: []string{topic}, Subjects: []string{topic},
MaxBytes: int64(*cfg.MaxMessageBytes), MaxBytes: int64(*cfg.MaxMessageBytes),
@ -101,6 +101,9 @@ func setupNATS(cfg *config.Kafka) (sarama.Consumer, sarama.SyncProducer) {
MaxAge: maxLifeTime, MaxAge: maxLifeTime,
Duplicates: maxLifeTime / 2, Duplicates: maxLifeTime / 2,
}) })
if err != nil {
logrus.WithError(err).WithField("stream", sn).Fatal("unable to add nats stream")
}
} }
} }