class AsyncJobAdapter
ActiveJob adapter for async-job, providing asynchronous job processing capabilities.
Definitions
def initialize(dispatcher = ::Async::Job::Adapter::ActiveJob::Railtie.dispatcher)
Initialize the adapter with a dispatcher.
Signature
-
parameter
dispatcher
Object
The job dispatcher, defaults to the Railtie dispatcher.
Implementation
def initialize(dispatcher = ::Async::Job::Adapter::ActiveJob::Railtie.dispatcher)
@dispatcher = dispatcher
end
def enqueue(job)
Enqueue a job for processing.
Signature
-
parameter
job
ActiveJob::Base
The job to enqueue.
Implementation
def enqueue(job)
Sync do
@dispatcher.call(job)
end
end
def enqueue_at(job, timestamp)
Enqueue a job for processing at a specific time.
Signature
-
parameter
job
ActiveJob::Base
The job to enqueue.
-
parameter
timestamp
Time
The time at which to enqueue the job.
Implementation
def enqueue_at(job, timestamp)
job.scheduled_at = timestamp
Sync do
@dispatcher.call(job)
end
end