Skip to content
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

Dynamic scheduling #13

Open
shirkavand opened this issue Dec 20, 2017 · 3 comments
Open

Dynamic scheduling #13

shirkavand opened this issue Dec 20, 2017 · 3 comments

Comments

@shirkavand
Copy link

shirkavand commented Dec 20, 2017

Does this work with dynamic-schedules?

I can't figure out how to use dynamic schedules with this gem, any help will be appreciated.

@JustinAiken
Copy link
Owner

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!

@shirkavand
Copy link
Author

shirkavand commented Dec 20, 2017

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?

@JustinAiken
Copy link
Owner

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 ? 😛 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants