rails/solid_queue

Dynamic scheduled tasks

Opened this issue ยท 5 comments

Hi @rosa,
I really appreciate the work you have done here and I am eager to switch over to solid_queue. There is only one thing left, which is holding me back.

Other gems like resque-scheduler or sidekiq-scheduler offer the ability to dynamically add or remove tasks to the schedule (see https://github.com/resque/resque-scheduler?tab=readme-ov-file#dynamic-schedules). Since everything seems to be stored in the database for solid_queue, this should be quite easy to achieve.

Maybe it is only a documentation issue and it is already possible (this would be awesome ๐Ÿคž ).
Happy to hear from you!

rosa commented

@wollistik, no, this is not supported yet, you didn't miss it ๐Ÿ˜…

This is something we can consider adding for sure. May I ask what's your use case for it?

Hi @rosa,
we have some cron like jobs, where the user is able to

  • Disable/Enable running the job
  • Change the schedule on when and how often the job is performed

Therefore the dynamic scheduling feature was really nice to implement these requirements.

But after I thought about this the last two days, I might be completely redesign this feature and come up with a different solution, because it was rarely used and still required some quirks to get it working.

rosa commented

Ahh got it! That makes sense ๐Ÿ‘ Yes, I thought a bit more about it yesterday and this is something I want to implement eventually ๐Ÿ˜Š

Maybe this helps, but the way I implemented dynamic cron schedules is by having one job run every minute and check if the cron schedule matches the one stored in my database table, with my table containing cron expressions. I use Fugit to check if the cron matches the current time.

@abrunner94 Even I have done a similar thing. Mine is not exactly the cron like scheduling but I am having different schedules.
First task is scheduled to be executed after 15 days and then onwards every alternate days.
So in the execution of first job I enqueue next job and in that job I keep enqueueing next jobs every 2 days as per condition.