This pull request adds support for the GETJOB argument WITHCOUNTERS (see #1).
GETJOB WITHCOUNTERS returns two extra pieces of information for each job:
The nacks counter - the number of times the job has been NACked and returned to the queue for a retry
The additional-deliveries counter - the number of times the job has been requeued for other reasons, eg. worker timeout
These two counters can help the client to handle job failures more precisely. For example, the client may decide to retry a failed job three times, but on the fourth failure remove the job from the queue, move it to a dead letter queue and inform the administrators.
I have added documentation as well as tests according to how other classes are covered.
Please, do a code review and let me know what I should fix and improve.
Two formal notes:
The pull request has two parts/main commits.
The first one adds support for WITHCOUNTERS in GETJOB.
The second one makes WITHCOUNTERS the default behavior of Queue::pull() so that pull()-ed jobs automatically contain the counters. Thus if the user goes the easy way and uses Queue instead of Client, they will be able to read the counters right away.
If you're not okay with it, we can leave the support just in the Client.
This pull request is based on the jobinterface branch which is not merged yet (see #6). The diff therefore shows also the contents of #6. The jobinterface pull request should be reviewed before this. Either Github then automatically adjusts the diff, or I will do a rebase + force pull so that we see the real diff.
Thank you for the code review and any suggestions.
This pull request adds support for the
GETJOB
argumentWITHCOUNTERS
(see #1).GETJOB WITHCOUNTERS
returns two extra pieces of information for each job:nacks
counter - the number of times the job has been NACked and returned to the queue for a retryadditional-deliveries
counter - the number of times the job has been requeued for other reasons, eg. worker timeoutThese two counters can help the client to handle job failures more precisely. For example, the client may decide to retry a failed job three times, but on the fourth failure remove the job from the queue, move it to a dead letter queue and inform the administrators.
I have added documentation as well as tests according to how other classes are covered. Please, do a code review and let me know what I should fix and improve.
Two formal notes:
WITHCOUNTERS
inGETJOB
.WITHCOUNTERS
the default behavior ofQueue::pull()
so thatpull()
-ed jobs automatically contain the counters. Thus if the user goes the easy way and usesQueue
instead ofClient
, they will be able to read the counters right away.If you're not okay with it, we can leave the support just in the Client.
jobinterface
branch which is not merged yet (see #6). The diff therefore shows also the contents of #6. Thejobinterface
pull request should be reviewed before this. Either Github then automatically adjusts the diff, or I will do a rebase + force pull so that we see the real diff.Thank you for the code review and any suggestions.