Dynamic scheduling
Does this work with dynamic-schedules?
I can't figure out how to use dynamic schedules with this gem, any help will be appreciated.
In theory it might.. Combining their example with this gem would look something like
config = {}
config[:send_emails] = {}
config[:send_emails][:class] = "SendEmail"
config[:send_emails][:args] = 'POC email subject'
config[:send_emails][:every] = ['1h', {first_in: 5.minutes}]
config[:send_emails][:persist] = true
# Wrap that object with this gem:
wrapped_schedule = ActiveScheduler::ResqueWrapper.wrap config
# Then pass it to resque as dynamic
Resque::Scheduler.dynamic = true
Resque.set_schedule("send_email", wrapped_schedule[:send_email])
Give it a shot, let me know if it works!
Hey Justin, thanks for your fast reply!
Reading your code i am wondering about these lines:
Resque::Scheduler.dynamic = true
Resque.set_schedule("send_email", wrapped_schedule[:send_email])
It seems we are not using ActiveJob there, seems that we are accessing Resque "directly" and queuing a job, instead of Using any ActiveJob interface, am i right? Based on this idea, what i was trying to do was something around (i know this is not suported, just take it as ane example):
...
ActiveJob::Scheduler.dynamic = true
...
class SomeJob < ActiveJob::Base
...
def perform(arg1, arg2)
...
end
end
SomeJob.set_schedule(schedule)
# or
SomeJob.perform_with_schedule(schedule)
Does that makes sense?
Oh yeah... that would be a great deal new functionally.. don't think I'll get around to adding it. Probably would accept a PR if it was very clean with tons of tests, and didn't break how it works now; might be best to add that as a separate gem them though (active_dynamic_scheduler ? 😛 )