refactor: Update Civial Aviation Authority Telegram message processor usage in main.go and add NATS server connection logging
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ func main() {
|
|||||||
func setupApp() *cli.App {
|
func setupApp() *cli.App {
|
||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "telegram message process",
|
Name: "telegram message process",
|
||||||
Usage: "A Civial Aviation Authority Telegram message processor",
|
Usage: "A Civial Aviation Authority Telegram Message Processor",
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Subscribe(config *config.Config, marshaler *handlers.PlainTextMarshaler, handler *handlers.MessageHandler) {
|
func Subscribe(config *config.Config, marshaler *handlers.PlainTextMarshaler, handler *handlers.MessageHandler) {
|
||||||
// marshaler := &PlainTextMarshaler{}
|
|
||||||
logger := watermill.NewStdLogger(false, false)
|
logger := watermill.NewStdLogger(false, false)
|
||||||
options := []nc.Option{
|
options := []nc.Option{
|
||||||
nc.RetryOnFailedConnect(true),
|
nc.RetryOnFailedConnect(true),
|
||||||
@@ -34,6 +33,8 @@ func Subscribe(config *config.Config, marshaler *handlers.PlainTextMarshaler, ha
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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})
|
logger.Info("Subscribing to NATS topic", map[string]interface{}{"topic": config.Subscription.Topic})
|
||||||
|
|
||||||
defer subscriber.Close()
|
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})
|
logger.Error("Failed to subscribe to NATS topic", err, map[string]interface{}{"topic": config.Subscription.Topic})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for msg := range messages {
|
for msg := range messages {
|
||||||
handler.HandleMessage(msg)
|
handler.HandleMessage(msg)
|
||||||
msg.Ack()
|
msg.Ack()
|
||||||
|
|||||||
Reference in New Issue
Block a user