refactor: Update Civial Aviation Authority Telegram message processor usage in main.go and add NATS server connection logging

This commit is contained in:
windyboy
2024-08-05 15:58:46 +08:00
parent 3c37410737
commit bef663ca3d
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -11,7 +11,6 @@ import (
)
func Subscribe(config *config.Config, marshaler *handlers.PlainTextMarshaler, handler *handlers.MessageHandler) {
// marshaler := &PlainTextMarshaler{}
logger := watermill.NewStdLogger(false, false)
options := []nc.Option{
nc.RetryOnFailedConnect(true),
@@ -34,6 +33,8 @@ func Subscribe(config *config.Config, marshaler *handlers.PlainTextMarshaler, ha
if err != nil {
panic(err)
}
logger.Info("NATS server connected", map[string]interface{}{"url": config.Nats.URL})
logger.Info("Subscribing to NATS topic", map[string]interface{}{"topic": config.Subscription.Topic})
defer subscriber.Close()
@@ -42,6 +43,7 @@ func Subscribe(config *config.Config, marshaler *handlers.PlainTextMarshaler, ha
logger.Error("Failed to subscribe to NATS topic", err, map[string]interface{}{"topic": config.Subscription.Topic})
return
}
for msg := range messages {
handler.HandleMessage(msg)
msg.Ack()