class ActiveJob::QueueAdapters::AsyncAdapter
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_job/queue_adapters/async_adapter.rbs class ActiveJob::QueueAdapters::AsyncAdapter def initialize: (**Hash executor_options) -> void end
short-lived jobs. Fine for dev/test; bad for production.
jobs. Since jobs share a single thread pool, long-running jobs will block
The adapter uses a Concurrent Ruby thread pool to schedule and execute
idletime: 600.seconds
max_threads: 2 * Concurrent.processor_count,
min_threads: 1,
config.active_job.queue_adapter = ActiveJob::QueueAdapters::AsyncAdapter.new <br>
pass your own config:
To configure the adapter’s thread pool, instantiate the adapter and
config.active_job.queue_adapter = :async
To use this adapter, set queue adapter to :async
:
production since it drops pending jobs on restart.
it doesn’t need an external infrastructure, but it’s a poor fit for
This is the default queue adapter. It’s well-suited for dev/test since
The Async adapter runs jobs with an in-process thread pool.
== Active Job Async adapter
def enqueue(job) # :nodoc:
def enqueue(job) # :nodoc: @scheduler.enqueue JobWrapper.new(job), queue_name: job.queue_name end
def enqueue_at(job, timestamp) # :nodoc:
def enqueue_at(job, timestamp) # :nodoc: @scheduler.enqueue_at JobWrapper.new(job), timestamp, queue_name: job.queue_name end
def immediate=(immediate) # :nodoc:
Used for our test suite.
def immediate=(immediate) # :nodoc: @scheduler.immediate = immediate end
def initialize(**executor_options)
Experimental RBS support (using type sampling data from the type_fusion
project).
def initialize: (** executor_options) -> void
This signature was generated using 1 sample from 1 application.
def initialize(**executor_options) @scheduler = Scheduler.new(**executor_options) end
def shutdown(wait: true) # :nodoc:
Waits for termination by default. Pass `wait: false` to continue.
any new jobs following the executor's fallback policy (`caller_runs`).
Gracefully stop processing jobs. Finishes in-progress work and handles
def shutdown(wait: true) # :nodoc: @scheduler.shutdown wait: wait end