Allow job classes to define default job options
Closed this issue · 0 comments
myronmarston commented
It's nice to be able to set job options directly in the job class; that way, when your app enqueues that type of job from multiple places, each place does not have to pass the same job options to queue.put
. Here's an API @dlecocq and I discussed:
class MyJob
def self.perform(job)
end
def self.default_job_options(data)
{ jid: jid_for(data) }
end
end
Essentially, a job class can define a default_job_options
method. If it's defined, queue.put(MyJob...)
will use it to get default job options. A single use of queue.put(MyJob...)
can override default options by passing its own options.