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:
+3
-6
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user