From f785d1a3a4009ebad833fa38d9a4c3f5f90c59db Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Wed, 13 Jul 2022 13:24:32 -0400 Subject: [PATCH] log message acknowledgement --- internal/worker/notifications.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/worker/notifications.go b/internal/worker/notifications.go index 0392554..c95c196 100644 --- a/internal/worker/notifications.go +++ b/internal/worker/notifications.go @@ -137,16 +137,20 @@ func NewNotificationsConsumer(nw *notificationsWorker, tag int) *notificationsCo func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) { id := delivery.Payload() - defer func(id string) { + defer func() { key := fmt.Sprintf("locks:accounts:%s", id) if err := nc.redis.Del(nc, key).Err(); err != nil { nc.logger.Error("failed to remove account lock", zap.Error(err), zap.String("key", key)) } - }(id) + }() nc.logger.Debug("starting job", zap.String("account#reddit_account_id", id)) - defer func() { _ = delivery.Ack() }() + defer func() { + if err := delivery.Ack(); err != nil { + nc.logger.Error("failed to acknowledge message", zap.Error(err), zap.String("account#reddit_account_id", id)) + } + }() now := time.Now()