mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 07:25:56 +03:00
[GH-ISSUE #379] [FEATURE REQUEST] Dynamic Register Periodic Tasks #2188
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#2188
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 @zhaolion on GitHub (Jan 13, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/379
Originally assigned to: @hibiken on GitHub.
feature request idea
Currently periodic tasks need to be bound to a period at runtime, is it possible to support that client can register a dynamic periodic tasks, similar to
Register(task, ... options)Describe alternatives you've considered
Some of our business scenarios will perform periodic tasks with different cycles based on some user data.
If this feature is supported, it will be very easy to use. 😆
I look forward to hearing from you for more contextual information and ideas. 😆
@hibiken commented on GitHub (Jan 15, 2022):
Hi @zhaolion thank you for creating this feature request!
You can actually call
(*Scheduler).Registerdynamically. However, a problem with the current implementation of Scheduler is that it doesn't persist the registered tasks and their schedule in persistent store, so if that process is restarted, it doesn't know what tasks were registered before. (FYI: I'm planning on changing this in the future so that the call toRegisterwrites that entry to redis so that it can survive restarts).I'll look into this more. But unfortunately asynq doesn't offer any support for this use case, right now.
I found this distributed cron service (https://github.com/distribworks/dkron), but I never used it before and not sure if it helps with your use case.
@zhaolion commented on GitHub (Jan 16, 2022):
Thank you for your reply 🙌. I think what you are planning to do is a better realized idea. The ability for periodic tasks to be stored and updated is a very exciting feature.
Also thank you very much for some ideas and references to the repository - dkron, i will try to make some demos to see whether I can solve some of my case.
Finally, considering that you are already planning to do some related features, I would close this issue. Thanks again for your response. 👏
@hibiken commented on GitHub (Jan 17, 2022):
Hi @zhaolion, I was doing a bit more research around this topic and I came across this page on sidekiq's Wiki (Sidekiq is a popular background job processing library in Ruby, and Asynq was heavily inspired by sidekiq).
Suggested solution in the wiki applies to users of Asynq as well.
Basic idea is to store dynamic periodic task configuration in a database; And set up a periodic task to query this database table to check whether we need to enqueue dynamic periodic tasks.
The configuration includes data such as:
type + user_idin the example above)For example, you can store the above data in a table
PeriodicTaskConfigsin a relational database. And set up a periodic task to query this table every minute and decide whether to enqueue a task. When you enqueue a task, you would update theNextRunTimevalue.Let me know if this makes sense. I may spend some time to update Asynq's Wiki page with this info 👍
@zhaolion commented on GitHub (Jan 17, 2022):
Hi @hibiken , Thank you so much for your research ! 👏
After reading your solutions, this is a better practice to solve my problems. I would very much like to see some updates on this topic.
@hibiken commented on GitHub (Jan 22, 2022):
FYI: Just released a new version v0.21 which includes
PeriodicTaskManager, which allows you to dynamically add/remove periodic tasks. See this wiki page for an example.This is a new feature so any feedback is appreciated!
@christopherPMello commented on GitHub (Sep 29, 2024):
Hi @hibiken, thanks for your work on the PeriodicTaskManager feature. Does this feature support payloads?
something like: