Skip to content

Commit 28fdf06

Browse files
committed
don't read topic and consumer group id from runtime configuration
These won't be changing at runtime, so there's no need to complicate the initialization by making these configurable. The topic's prefix is configurable, and that's the part that will change from environment to environment at runtime. BACK-2554
1 parent d6b82b5 commit 28fdf06

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

data/service/service/standard.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -483,22 +483,13 @@ func (s *Standard) initializeAlertsEventsHandler() error {
483483
return err
484484
}
485485

486-
// In addition to the CloudEventsConfig, additional specific config values
487-
// are needed.
488-
config := &struct {
489-
KafkaAlertsTopics []string `envconfig:"KAFKA_ALERTS_TOPICS" default:"alerts,deviceData.alerts"`
490-
KafkaAlertsGroupID string `envconfig:"KAFKA_ALERTS_CONSUMER_GROUP" required:"true"`
491-
}{}
492-
if err := envconfig.Process("", config); err != nil {
493-
return errors.Wrap(err, "Unable to process envconfig")
494-
}
495-
486+
topics := []string{"data.alerts", "data.deviceData.alerts"}
496487
// Some kafka topics use a `<env>-` as a prefix. But MongoDB CDC topics are created with
497488
// `<env>.`. This code is using CDC topics, so ensuring that a `.` is used for alerts events
498489
// lines everything up as expected.
499490
topicPrefix := strings.ReplaceAll(commonConfig.KafkaTopicPrefix, "-", ".")
500-
prefixedTopics := make([]string, 0, len(config.KafkaAlertsTopics))
501-
for _, topic := range config.KafkaAlertsTopics {
491+
prefixedTopics := make([]string, 0, len(topics))
492+
for _, topic := range topics {
502493
prefixedTopics = append(prefixedTopics, topicPrefix+topic)
503494
}
504495

@@ -517,7 +508,7 @@ func (s *Standard) initializeAlertsEventsHandler() error {
517508

518509
runnerCfg := dataEvents.SaramaRunnerConfig{
519510
Brokers: commonConfig.KafkaBrokers,
520-
GroupID: config.KafkaAlertsGroupID,
511+
GroupID: "alerts",
521512
Topics: prefixedTopics,
522513
Sarama: commonConfig.SaramaConfig,
523514
MessageConsumer: &dataEvents.AlertsEventsConsumer{

0 commit comments

Comments
 (0)