refactor: Update nats subscription handling
The code changes in `sub.go` update the handling of NATS subscriptions. The `Subscribe` function now takes in a `config` parameter, allowing for more flexibility in configuring the subscription. Additionally, the `Subscribe` function now uses the `handler` and `marshaler` parameters to handle incoming messages and marshal/unmarshal data, respectively. These changes improve the modularity and extensibility of the code when working with NATS subscriptions.
This commit is contained in:
+4
-2
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"caatsm/internal/config"
|
||||
"caatsm/internal/handlers"
|
||||
"caatsm/internal/nats"
|
||||
"caatsm/pkg/utils"
|
||||
|
||||
@@ -24,6 +25,7 @@ func main() {
|
||||
fmt.Println("Loaded configuration successfully")
|
||||
|
||||
log.Info("Starting nats subscriber")
|
||||
subscribe := nats.NewNatsHandler(cfg)
|
||||
subscribe.Subscribe()
|
||||
handler := handlers.NewNatsHandler(cfg)
|
||||
|
||||
nats.Subscribe(cfg, &handlers.PlainTextMarshaler{}, handler)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user