mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 07:25:56 +03:00
[GH-ISSUE #362] [FEATURE REQUEST] On fail cleanup task #2183
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#2183
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 @sersh88 on GitHub (Dec 8, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/362
Originally assigned to: @hibiken on GitHub.
For some tasks I need to prepare some files and need to clean them if task failed after all defined attempts.
So, it will be very useful to define a cleanup task for a task to run after it's failed. It can be done as passing option to NewTask method.
So, after our original task is failed a new cleanup task will be automatically created with the same payload or maybe with custom payload.
@crossworth commented on GitHub (Dec 8, 2021):
You can implement this in different ways:
You can define a custom error and check it on the middleware/error handler (or check the task type) and enqueue the cleanup task.
Maybe it will be possible with the workflow feature as well (https://github.com/hibiken/asynq/issues/244).
@sersh88 commented on GitHub (Dec 8, 2021):
But error handler and middleware ProcessTask will react on every retry, right? So, I can't know if this was the last attempt to run the task or not?
@crossworth commented on GitHub (Dec 8, 2021):
https://pkg.go.dev/github.com/hibiken/asynq#GetRetryCount and
https://pkg.go.dev/github.com/hibiken/asynq#GetMaxRetry