mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 07:25:56 +03:00
[GH-ISSUE #172] [FEATURE REQUEST] Support cancelation of scheduled tasks #2078
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#2078
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 @kamatama41 on GitHub (Jun 15, 2020).
Original GitHub issue: https://github.com/hibiken/asynq/issues/172
Originally assigned to: @hibiken on GitHub.
Is your feature request related to a problem? Please describe.
We sometimes want to cancel specific tasks.
Describe the solution you'd like
Add a method to cancel them to the asynq client.
Maybe need a method to list all scheduled tasks as well in order to know their ID.
(ref #50)
@hibiken commented on GitHub (Jun 15, 2020):
@kamatama41 Thank you for opening this issue!
As you said, #50 is related to this. When I opened #50 I was thinking about adding a public sub-package (e.g.
"github.com/hibiken/asynq/x/inspect") and expose methods likeListScheduledTasksDeleteScheduledTask(id string)from the sub-package. But I can see the benefit of adding directly to
Clientas you suggested. I'll consider both options when I get to work on #50 👍In the meantime, you have a few options to cancel scheduled tasks.
Option 1 : Use asynq CLI to list and delete scheduled tasks
You can use the CLI
lsanddelcommands.Option 2: Use
Deadlineoption when enqueueingIf your tasks has specific deadline, you can use
Deadlineoption when enqueueing the tasks.With this approach, you need to make sure that your
Handlerchecks the passed context Done channel and return an error if Done channel is closed. Please see an example here.Please let me know if this workaround works for you. If not, I can prioritize #50. Thank you :)
@kamatama41 commented on GitHub (Jun 15, 2020):
Thanks for the quick response and suggesting workarounds!
Option 2 is not for us because the reason for cancelation is that the task is no longer needed or with wrong parameter, so it doesn't have specific deadline.
About option 1, it would work for us. However, as we are using asynq client on a Go application, we eventually would like to cancel tasks on the app via client.
@hibiken commented on GitHub (Jun 17, 2020):
I see. Thanks for sharing context :)
What you are looking for is actually implemented but they are not part of public API yet. It's in one of our internal packages called
"rdb"andinspect.gofile includes all the methods to inspect and modify current state of queues and tasks.Here's the link to the methods that may help you.
ListScheduledTaskDeleteScheduledTaskAt this point I'm still a bit hesitant to make these public API from the core package.
My current thinking is to expose this via "experimental" package under
github.com/hibiken/asynq/xso that we don't have to worry too much about making API changes in the experimental package.I can probably get to that in the next few weeks, but in the meantime please feel free to fork and use these methods 👍