-
Notifications
You must be signed in to change notification settings - Fork 175
Dynamic scheduled tasks #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ed10591
to
ebb8716
Compare
ebb8716
to
ebd9629
Compare
Hi @rosa 👋, could you please take a look at this PR when you have a moment? Thanks so much! |
Hey @cupatea, thanks for this! It's a good start, but it needs a few changes. The main ones are:
And then some other more specific changes that I'll note in the code. |
@@ -93,7 +93,7 @@ def default_options | |||
end | |||
|
|||
def invalid_tasks | |||
recurring_tasks.select(&:invalid?) | |||
static_recurring_tasks.select(&:invalid?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to change names. It's clear the tasks here are static since this comes from the recurring.yml
configuration. We don't need to rename anything here.
recurring_schedule.update_scheduled_tasks.tap do |updated_tasks| | ||
if updated_tasks.any? | ||
process.update_columns(metadata: metadata.compact) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is mixing actions at very different levels, making it aware of details it shouldn't need to know, like how to update the metadata for its registered process record, or whether the recurring schedule changed. It should change, perhaps to something like
recurring_schedule.reload!
if recurring_schedule.changed?
refresh_registered_process
end
And refresh_registered_process
would go in SolidQueue::Processes::Registrable
.
Fixes #186
Add resque-scheduler style dynamic schedules feature, allowing you to add or remove recurring tasks at runtime without touching your static config file.
What’s new:
SolidQueue::RecurringTask
model.SolidQueue::Scheduler::RecurringSchedule
to distinguish static vs. dynamic schedules.@configured_tasks
now includes static and dynamic tasks.SolidQueue::Scheduler::RecurringSchedule.update_scheduled_tasks
:SolidQueue::Configuration
no longer requires a non-blank static config file - pure dynamic scheduling is now supported.SolidQueue::Scheduler
watches for changes after launch and updates its metadata so the running process always reflects the true set of recurring tasks.Tests verify that adding or dropping dynamic tasks at runtime correctly updates what’s scheduled.