Repository navigation
Conversation
Setting `SolidQueue::RecurringTask.default_job_class` to an app job class loads that class, and the `RecurringTask` model with it, at boot. And since `RecurringTask` is reloadable, the setting is lost on reload unless it's set in `to_prepare`. The new `SolidQueue.recurring_task_job_class` setting lives on the non-reloadable `SolidQueue` module, so it can be set as `config.solid_queue.recurring_task_job_class` like the other settings. It accepts a class name, resolved when a task is first enqueued, so the job class stays autoloaded and can be customized with Zeitwerk's `on_load`. `RecurringTask.default_job_class` is kept as a deprecated alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Customizing the job class that runs
commandrecurring tasks currently looks like this:This has two downsides:
MyRecurringCommandJobat boot, along withSolidQueue::RecurringTask(and Active Record with it).SolidQueue::RecurringTasklives in the engine'sapp/models, so it's reloadable. A value set inafter_initializeis lost on the first reload; it has to be set into_prepareto stick.This adds a
SolidQueue.recurring_task_job_classsetting that takes the job class name:SolidQueuemodule, like the other settings, so it can be set throughconfig.solid_queueand survives reloads."SolidQueue::RecurringJob".SolidQueue::RecurringTask.default_job_class(reader and writer) still works and delegates to the new setting, with a deprecation warning.