class Dispatcher
A dispatcher for managing multiple definitions.
Definitions
def initialize(definitions = {}, aliases = {})
Prepare the dispacher with the given definitions and aliases.
Signature
-
parameter
definitions
Hash(String, Proc)
The definitions to use constructing queues.
-
parameter
aliases
Hash(String, Proc)
The aliases for the definitions.
Implementation
def initialize(definitions = {}, aliases = {})
@definitions = definitions
@aliases = aliases
@queues = {}
end
attr :definitions
Signature
-
attribute
Hash(String, Proc)
The definitions to use for processing jobs.
attr :aliases
Signature
-
attribute
Hash(String, String)
The aliases for the definitions.
attr :queues
Signature
-
attribute
Hash(String, Queue)
The queues that have been constructed.
def [](name)
Look up a queue by name, constructing it if necessary using the given definition.
Signature
-
parameter
name
String
The name of the queue.
Implementation
def [](name)
@queues.fetch(name) do
definition = @definitions.fetch(name)
@queues[name] = build(definition)
end
end
def start(name)
Start processing jobs in the given queue.
Implementation
def start(name)
self[name].server.start
end