Class: RCelery::Task::Runner
- Inherits:
-
Object
- Object
- RCelery::Task::Runner
- Includes:
- States
- Defined in:
- lib/rcelery/task/runner.rb
Constant Summary
Constants included from States
States::FAILURE, States::RETRY, States::SUCCESS
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(message) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(message) ⇒ Runner
Returns a new instance of Runner.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rcelery/task/runner.rb', line 14 def initialize() @task = Task.all_tasks[['task']] @task_id = ['id'] @eager = ['eager'].nil? ? false : ['eager'] @args = [['args'], ['kwargs']].flatten.compact @args.pop if @args.last.is_a?(Hash) && @args.last.empty? @queue = Task.result_queue(@task_id) unless eager_mode? @task.request.update( :task_id => @task_id, :retries => ['retries'] || 0, :args => ['args'], :kwargs => ['kwargs'] ) end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
12 13 14 |
# File 'lib/rcelery/task/runner.rb', line 12 def result @result end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
12 13 14 |
# File 'lib/rcelery/task/runner.rb', line 12 def status @status end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
12 13 14 |
# File 'lib/rcelery/task/runner.rb', line 12 def task @task end |
Instance Method Details
#execute ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rcelery/task/runner.rb', line 31 def execute result = @task.method.call(*@args) @status = SUCCESS @result = result publish_result if publish_result? rescue RetryError => raised @result = raised @status = RETRY rescue Exception => raised @result = raised @status = FAILURE publish_result if publish_result? ensure @task.request.clear end |