From 9663fdfc43b248b148cd57b675ce40c48f330477 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sat, 7 Feb 2026 11:57:54 -0600 Subject: [PATCH] Updated main.go to register the postgres and NATS sinks in addition to the stdout sink. --- cmd/weatherfeeder/config.yml | 9 +++++++++ cmd/weatherfeeder/main.go | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/weatherfeeder/config.yml b/cmd/weatherfeeder/config.yml index 4fc86cc..2fd3073 100644 --- a/cmd/weatherfeeder/config.yml +++ b/cmd/weatherfeeder/config.yml @@ -69,6 +69,12 @@ sinks: driver: stdout params: {} + - name: nats_weatherfeeder + driver: nats + params: + url: nats://nats:4222 + exchange: weatherfeeder + # - name: logfile # driver: file # params: @@ -78,5 +84,8 @@ routes: - sink: stdout kinds: ["observation", "forecast", "alert"] + - sink: nats_weatherfeeder + kinds: ["observation", "forecast", "alert"] + # - sink: logfile # kinds: ["observation", "alert", "forecast"] diff --git a/cmd/weatherfeeder/main.go b/cmd/weatherfeeder/main.go index 0e39fac..fcbfcac 100644 --- a/cmd/weatherfeeder/main.go +++ b/cmd/weatherfeeder/main.go @@ -40,12 +40,17 @@ func main() { srcReg := fksources.NewRegistry() wfsources.RegisterBuiltins(srcReg) - // Minimal sink set to compile: stdout only. + // Compile stdout, Postgres, and NATS sinks for weatherfeeder. The former is useful for debugging and the latter are the main intended outputs. sinkReg := fksinks.NewRegistry() sinkReg.Register("stdout", func(cfg config.SinkConfig) (fksinks.Sink, error) { return fksinks.NewStdoutSink(cfg.Name), nil }) - + sinkReg.Register("postgres", func(cfg config.SinkConfig) (fksinks.Sink, error) { + return fksinks.NewPostgresSinkFromConfig(cfg) + }) + sinkReg.Register("nats", func(cfg config.SinkConfig) (fksinks.Sink, error) { + return fksinks.NewNATSSinkFromConfig(cfg) + }) // --- Build sources into scheduler jobs --- var jobs []fkscheduler.Job for i, sc := range cfg.Sources {