Files
go-caatsm/cmd/main/main.go
T
windyboy 766925f7f9 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.
2024-07-30 10:25:59 +08:00

32 lines
599 B
Go

package main
import (
"caatsm/internal/config"
"caatsm/internal/handlers"
"caatsm/internal/nats"
"caatsm/pkg/utils"
"fmt"
)
func main() {
cfg, err := config.LoadConfig()
log := utils.GetLogger()
if err != nil {
fmt.Printf("Error loading configuration: %v\n", err)
return
}
if err := config.ValidateConfig(cfg); err != nil {
fmt.Printf("Invalid configuration: %v\n", err)
return
}
fmt.Println("Loaded configuration successfully")
log.Info("Starting nats subscriber")
handler := handlers.NewNatsHandler(cfg)
nats.Subscribe(cfg, &handlers.PlainTextMarshaler{}, handler)
}