class Railtie
A Rails-specific adapter for ActiveJob
that allows you to use Async::Job
as the queue.
Definitions
DEFAULT_QUEUE_DEFINITION
The default queue definition for processing jobs, using the Inline
backend.
Implementation
DEFAULT_QUEUE_DEFINITION = proc do
dequeue Processor::Inline
end
attr :definitions
The queues that are available for processing jobs.
attr :aliases
The aliases for the definitions, if any.
attr :dispatcher
Thed default dispatcher for processing jobs.
def define_queue(name, *aliases, &block)
Define a new backend for processing jobs.
Signature
-
parameter
name
String
The name of the backend.
-
parameter
aliases
Array(String)
The aliases for the backend.
-
parameter
block
Proc
The block that defines the backend.
Implementation
def define_queue(name, *aliases, &block)
name = name.to_s
@definitions[name] = block
if aliases.any?
alias_queue(name, *aliases)
end
end
def alias_queue(name, *aliases)
Define an alias for a queue.
Implementation
def alias_queue(name, *aliases)
aliases.each do |alias_name|
alias_name = alias_name.to_s
@aliases[alias_name] = name
end
end
def start(name = "default")
Start the job server with the given name.
Implementation
def start(name = "default")
@dispatcher.start(name)
end