mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 11:47:42 +00:00
clear lock after job succeeds too
This commit is contained in:
parent
eddf7b53d1
commit
4719ee091e
1 changed files with 2 additions and 3 deletions
|
@ -182,6 +182,8 @@ func NewConsumer(tag int, logger *logrus.Logger, statsd *statsd.Client, redis *r
|
||||||
func (c *Consumer) Consume(delivery rmq.Delivery) {
|
func (c *Consumer) Consume(delivery rmq.Delivery) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
defer c.redis.HDel(ctx, "locks:accounts", delivery.Payload())
|
||||||
|
|
||||||
c.logger.WithFields(logrus.Fields{
|
c.logger.WithFields(logrus.Fields{
|
||||||
"accountID": delivery.Payload(),
|
"accountID": delivery.Payload(),
|
||||||
}).Debug("starting job")
|
}).Debug("starting job")
|
||||||
|
@ -305,7 +307,6 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
|
||||||
|
|
||||||
delivery.Reject()
|
delivery.Reject()
|
||||||
} else {
|
} else {
|
||||||
c.redis.HDel(ctx, "locks:accounts", delivery.Payload())
|
|
||||||
delivery.Ack()
|
delivery.Ack()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -335,7 +336,6 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
|
||||||
"accountID": delivery.Payload(),
|
"accountID": delivery.Payload(),
|
||||||
}).Debug("populating first message ID to prevent spamming")
|
}).Debug("populating first message ID to prevent spamming")
|
||||||
|
|
||||||
c.redis.HDel(ctx, "locks:accounts", delivery.Payload())
|
|
||||||
delivery.Ack()
|
delivery.Ack()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -396,7 +396,6 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.redis.HDel(ctx, "locks:accounts", delivery.Payload())
|
|
||||||
delivery.Ack()
|
delivery.Ack()
|
||||||
|
|
||||||
c.logger.WithFields(logrus.Fields{
|
c.logger.WithFields(logrus.Fields{
|
||||||
|
|
Loading…
Reference in a new issue