Class: Zenaton::Engine
- Inherits:
-
Object
- Object
- Zenaton::Engine
- Includes:
- Singleton
- Defined in:
- lib/zenaton/engine.rb
Overview
Zenaton Engine is a singleton class that stores a reference to the current client and processor. It then handles job processing either locally or through the processor with Zenaton workers To access the instance, call ‘Zenaton::Engine.instance`
Instance Attribute Summary collapse
- #processor ⇒ Object writeonly
Instance Method Summary collapse
-
#dispatch(jobs) ⇒ Object
Executes jobs asynchronously.
-
#execute(jobs) ⇒ Array<String>?
Executes jobs synchronously.
Instance Attribute Details
#processor=(value) ⇒ Object (writeonly)
19 20 21 |
# File 'lib/zenaton/engine.rb', line 19 def processor=(value) @processor = value end |
Instance Method Details
#dispatch(jobs) ⇒ Object
Executes jobs asynchronously
39 40 41 42 43 44 |
# File 'lib/zenaton/engine.rb', line 39 def dispatch(jobs) jobs.map(&method(:check_argument)) jobs.map(&method(:local_dispatch)) if process_locally?(jobs) @processor&.process(jobs, false) unless jobs.length.zero? nil end |
#execute(jobs) ⇒ Array<String>?
Executes jobs synchronously
30 31 32 33 34 |
# File 'lib/zenaton/engine.rb', line 30 def execute(jobs) jobs.map(&method(:check_argument)) return jobs.map(&:handle) if process_locally?(jobs) @processor.process(jobs, true) end |