refactor: Update NATS subscription logic and configuration

The code changes in `main.go` update the NATS subscription logic and configuration. The `Subscribe` function now uses the `NatsHandler` struct to handle the subscription. The `NewNatsHandler` function is added to create a new instance of the `NatsHandler` with the provided configuration. The configuration values are passed to the `NatsSubscriber` constructor to set up the NATS subscription. This refactor improves the modularity and readability of the NATS subscription code.
This commit is contained in:
windyboy
2024-07-21 23:09:29 +08:00
parent 29fecbbe6c
commit 24c9beeb13
3 changed files with 95 additions and 12 deletions
+3 -6
View File
@@ -2,9 +2,8 @@ package main
import (
"caatsm/internal/config"
"caatsm/internal/nats"
"caatsm/pkg/utils"
"github.com/sirupsen/logrus"
)
func main() {
@@ -19,8 +18,6 @@ func main() {
utils.Logger.Info("Loaded configuration successfully")
// Example usage
utils.Logger.WithFields(logrus.Fields{
"url": cfg.Nats.URL,
}).Info("NATS configuration")
subscribe := nats.NewNatsHandler(cfg)
subscribe.Subscribe()
}