Class: ActiveJob::QueueAdapters::AsyncAdapter::Scheduler
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activejob/lib/active_job/queue_adapters/async_adapter.rb |
Constant Summary
-
DEFAULT_EXECUTOR_OPTIONS =
# File 'activejob/lib/active_job/queue_adapters/async_adapter.rb', line 75{ min_threads: 0, max_threads: ENV.fetch("RAILS_MAX_THREADS", 5).to_i, auto_terminate: true, idletime: 60, # 1 minute max_queue: 0, # unlimited fallback_policy: :caller_runs # shouldn't matter -- 0 max queue }.freeze
Class Method Summary
- .new(**options) ⇒ Scheduler constructor
Instance Attribute Summary
- #immediate rw
Instance Method Summary
Constructor Details
.new(**options) ⇒ Scheduler
# File 'activejob/lib/active_job/queue_adapters/async_adapter.rb', line 86
def initialize(** ) self.immediate = false @immediate_executor = Concurrent::ImmediateExecutor.new @async_executor = Concurrent::ThreadPoolExecutor.new(DEFAULT_EXECUTOR_OPTIONS.merge( )) end
Instance Attribute Details
#immediate (rw)
[ GitHub ]# File 'activejob/lib/active_job/queue_adapters/async_adapter.rb', line 84
attr_accessor :immediate
Instance Method Details
#enqueue(job, queue_name:)
[ GitHub ]# File 'activejob/lib/active_job/queue_adapters/async_adapter.rb', line 92
def enqueue(job, queue_name:) executor.post(job, &:perform) end
#enqueue_at(job, timestamp, queue_name:)
[ GitHub ]#executor
[ GitHub ]# File 'activejob/lib/active_job/queue_adapters/async_adapter.rb', line 110
def executor immediate ? @immediate_executor : @async_executor end
#shutdown(wait: true)
[ GitHub ]# File 'activejob/lib/active_job/queue_adapters/async_adapter.rb', line 105
def shutdown(wait: true) @async_executor.shutdown @async_executor.wait_for_termination if wait end