From 8733b1c1cfcffe546b4d8bebebd8fe8de784ea43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Rasmussen?= Date: Sat, 23 Jul 2022 19:15:42 +0200 Subject: [PATCH] Configure NATS for dwingest --- cmd/fermentord/loop.go | 6 +++--- cmd/fermentord/main.go | 12 ------------ internal/dwingest/nats.go | 1 - 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/cmd/fermentord/loop.go b/cmd/fermentord/loop.go index 63f91ea..706893d 100644 --- a/cmd/fermentord/loop.go +++ b/cmd/fermentord/loop.go @@ -36,9 +36,6 @@ func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config // Controller ctrl := controllers.NewChamberController("Chamber 1", *config) - // NATS - ingest := dwingest.NewDWIngest() - // Configuration reload loadConfiguration := func() { temperature.ConfigUpdate <- *config @@ -52,6 +49,9 @@ func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config loadConfiguration() viper.WatchConfig() + // NATS + ingest := dwingest.NewDWIngest() + gpio, err := hw.NewGpio() if err != nil { hub.CaptureException(err) diff --git a/cmd/fermentord/main.go b/cmd/fermentord/main.go index 608b55b..0a5bd27 100644 --- a/cmd/fermentord/main.go +++ b/cmd/fermentord/main.go @@ -41,18 +41,6 @@ func main() { log.Fatal(err) } - _, err = js.AddStream(&nats.StreamConfig{ - Name: config.NATS.Stream, - Subjects: []string{ - fmt.Sprintf("%v.*", config.NATS.Stream), - }, - Replicas: 2, - Retention: nats.WorkQueuePolicy, - }) - if err != nil { - log.Fatal(err) - } - // HTTP mux := http.NewServeMux() srv := &http.Server{ diff --git a/internal/dwingest/nats.go b/internal/dwingest/nats.go index e219cb5..d72efae 100644 --- a/internal/dwingest/nats.go +++ b/internal/dwingest/nats.go @@ -67,7 +67,6 @@ func (p *DWIngest) Run(ctx context.Context, wg *sync.WaitGroup, js nats.JetStrea return } - } }