clear lock after job succeeds too

This commit is contained in:
Andre Medeiros 2021-07-08 20:14:12 -04:00
parent eddf7b53d1
commit 4719ee091e

View file

@ -182,6 +182,8 @@ func NewConsumer(tag int, logger *logrus.Logger, statsd *statsd.Client, redis *r
func (c *Consumer) Consume(delivery rmq.Delivery) {
ctx := context.Background()
defer c.redis.HDel(ctx, "locks:accounts", delivery.Payload())
c.logger.WithFields(logrus.Fields{
"accountID": delivery.Payload(),
}).Debug("starting job")
@ -305,7 +307,6 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
delivery.Reject()
} else {
c.redis.HDel(ctx, "locks:accounts", delivery.Payload())
delivery.Ack()
}
return
@ -335,7 +336,6 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
"accountID": delivery.Payload(),
}).Debug("populating first message ID to prevent spamming")
c.redis.HDel(ctx, "locks:accounts", delivery.Payload())
delivery.Ack()
}
return
@ -396,7 +396,6 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
}
}
c.redis.HDel(ctx, "locks:accounts", delivery.Payload())
delivery.Ack()
c.logger.WithFields(logrus.Fields{