Class: GoodJob::Adapter
- Inherits:
-
Object
- Object
- GoodJob::Adapter
- Defined in:
- lib/good_job/adapter.rb
Instance Method Summary collapse
- #enqueue(job) ⇒ Object
- #enqueue_at(job, timestamp) ⇒ Object
-
#initialize(options = {}) ⇒ Adapter
constructor
A new instance of Adapter.
- #inline? ⇒ Boolean
- #shutdown(wait: true) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Adapter
Returns a new instance of Adapter.
3 4 5 6 |
# File 'lib/good_job/adapter.rb', line 3 def initialize( = {}) @options = @scheduler = InlineScheduler.new if inline? end |
Instance Method Details
#enqueue(job) ⇒ Object
12 13 14 |
# File 'lib/good_job/adapter.rb', line 12 def enqueue(job) enqueue_at(job, nil) end |
#enqueue_at(job, timestamp) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/good_job/adapter.rb', line 16 def enqueue_at(job, ) params = { queue_name: job.queue_name, priority: job.priority, serialized_params: job.serialize, } params[:scheduled_at] = Time.at() if good_job = GoodJob::Job.create(params) @scheduler.enqueue(good_job) if inline? end |
#inline? ⇒ Boolean
8 9 10 |
# File 'lib/good_job/adapter.rb', line 8 def inline? @options.fetch(:inline, false) end |
#shutdown(wait: true) ⇒ Object
28 29 30 |
# File 'lib/good_job/adapter.rb', line 28 def shutdown(wait: true) @scheduler&.shutdown(wait: wait) end |