mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #154] [QUESTION] Way to determine a task is a retry #1060
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#1060
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jimmy-ho on GitHub (May 26, 2020).
Original GitHub issue: https://github.com/hibiken/asynq/issues/154
Originally assigned to: @hibiken on GitHub.
Is there an easy way to determine if the current task being processed is a retry? It is not in the context I guess passed to ProcessTask, would be nice to have it in the Task perhaps.
This is useful if I have already completed some set of action, but then need to retry some aspect that failed - unless I need to store some relationship that a particular task failed and thus subsequent will be a retry?
I prefer I do not need to store this, as I see in redis we already are storing the number of retries which can be used as a determinant.
Maybe I have missed some means to be able to just get this information somehow?
@hibiken commented on GitHub (May 26, 2020):
Great question and thanks for opening this issue.
Current APIs don't offer an ability to determine whether a
Taskpassed to yourHandleris a retry task.I think it makes total sense to put task metadata such as
RetryCountin thecontextValue.I'll do a little bit of research and update this thread with a proposal 👍
@hibiken commented on GitHub (May 27, 2020):
Proposal
Here's my initial proposal. Please let me know if you have any thoughts or feedback 😃
Export functions to extract task metadata from context:
GetTaskID(ctx context.Context) (id string, ok bool)GetRetryCount(ctx context.Context) (n int, ok bool)GetMaxRetry(ctx context.Context) (n int, ok bool)Example
@jimmy-ho commented on GitHub (May 27, 2020):
@hibiken looks good to me, thanks for your time in looking into this.