Class: TaskTempest::Engine

Inherits:
Object show all
Includes:
Bootstrap, Callbacks, ErrorHandling, Settings
Defined in:
lib/task_tempest/engine.rb

Constant Summary

Constants included from Settings

Settings::DEFAULTS

Constants included from ErrorHandling

TaskTempest::ErrorHandling::SHUTDOWN_EXCEPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Settings

included

Methods included from ErrorHandling

#format_exception, #handle_shutdown_signal, #with_error_handling, #with_shutdown_handling

Methods included from Callbacks

#on_bookkeeping, #on_internal_exception, #on_require, #on_task_exception, #on_task_timeout

Methods included from Bootstrap

#after_initialize, #before_initialize, #bookkeeper, #bootstrap, #dispatcher, #init_bookkeeper, #init_dispatcher, #init_logging, #init_queue, #init_require, #init_task_logging, #init_tasks, #init_thread_pool, #logger, #queue, #storm, #task_logger

Class Method Details

.inherited(derived) ⇒ Object



17
18
19
# File 'lib/task_tempest/engine.rb', line 17

def self.inherited(derived)
  derived.settings = settings.dup
end

.runObject



37
38
39
# File 'lib/task_tempest/engine.rb', line 37

def self.run
  new.run
end

.submit(task_or_message, *args) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/task_tempest/engine.rb', line 29

def self.submit(task_or_message, *args)
  if task_or_message.kind_of?(TaskTempest::Task)
    submit_task(task_or_message, *args)
  else
    submit_message(task_or_message, *args)
  end
end

.submit_message(message, *args) ⇒ Object



21
22
23
# File 'lib/task_tempest/engine.rb', line 21

def self.submit_message(message, *args)
  new.queue.enqueue(message, *args)
end

.submit_task(task, *args) ⇒ Object



25
26
27
# File 'lib/task_tempest/engine.rb', line 25

def self.submit_task(task, *args)
  submit_message(task.to_message, *args)
end

Instance Method Details

#runObject



41
42
43
44
# File 'lib/task_tempest/engine.rb', line 41

def run
  bootstrap(:halt)
  with_shutdown_handling{ heartbeat while true }
end