Class: Postjob::Job
Overview
A job
Constant Summary collapse
- STATUSES =
%w(ok ready processing sleep err failed timeout)
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#error_backtrace ⇒ Object
readonly
Returns the value of attribute error_backtrace.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#failed_attempts ⇒ Object
readonly
Returns the value of attribute failed_attempts.
-
#full_id ⇒ Object
readonly
Returns the value of attribute full_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_sticky ⇒ Object
readonly
Returns the value of attribute is_sticky.
-
#last_worker_session_id ⇒ Object
readonly
Returns the value of attribute last_worker_session_id.
-
#max_attempts ⇒ Object
readonly
Returns the value of attribute max_attempts.
-
#next_run_at ⇒ Object
readonly
Returns the value of attribute next_run_at.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#recipients ⇒ Object
readonly
Returns the value of attribute recipients.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#root_id ⇒ Object
readonly
Returns the value of attribute root_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#sticky_host_id ⇒ Object
readonly
Returns the value of attribute sticky_host_id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#timed_out ⇒ Object
readonly
Returns the value of attribute timed_out.
-
#timing_out_at ⇒ Object
readonly
Returns the value of attribute timing_out_at.
-
#workflow ⇒ Object
readonly
Returns the value of attribute workflow.
-
#workflow_method ⇒ Object
readonly
Returns the value of attribute workflow_method.
-
#workflow_version ⇒ Object
readonly
Returns the value of attribute workflow_version.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Record
Constructor Details
This class inherits a constructor from Postjob::Record
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
21 22 23 |
# File 'lib/postjob/job.rb', line 21 def args @args end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
16 17 18 |
# File 'lib/postjob/job.rb', line 16 def created_at @created_at end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
28 29 30 |
# File 'lib/postjob/job.rb', line 28 def error @error end |
#error_backtrace ⇒ Object (readonly)
Returns the value of attribute error_backtrace.
30 31 32 |
# File 'lib/postjob/job.rb', line 30 def error_backtrace @error_backtrace end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
29 30 31 |
# File 'lib/postjob/job.rb', line 29 def @error_message end |
#failed_attempts ⇒ Object (readonly)
Returns the value of attribute failed_attempts.
24 25 26 |
# File 'lib/postjob/job.rb', line 24 def failed_attempts @failed_attempts end |
#full_id ⇒ Object (readonly)
Returns the value of attribute full_id.
14 15 16 |
# File 'lib/postjob/job.rb', line 14 def full_id @full_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/postjob/job.rb', line 12 def id @id end |
#is_sticky ⇒ Object (readonly)
Returns the value of attribute is_sticky.
35 36 37 |
# File 'lib/postjob/job.rb', line 35 def is_sticky @is_sticky end |
#last_worker_session_id ⇒ Object (readonly)
Returns the value of attribute last_worker_session_id.
34 35 36 |
# File 'lib/postjob/job.rb', line 34 def last_worker_session_id @last_worker_session_id end |
#max_attempts ⇒ Object (readonly)
Returns the value of attribute max_attempts.
25 26 27 |
# File 'lib/postjob/job.rb', line 25 def max_attempts @max_attempts end |
#next_run_at ⇒ Object (readonly)
Returns the value of attribute next_run_at.
22 23 24 |
# File 'lib/postjob/job.rb', line 22 def next_run_at @next_run_at end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
13 14 15 |
# File 'lib/postjob/job.rb', line 13 def parent_id @parent_id end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
17 18 19 |
# File 'lib/postjob/job.rb', line 17 def queue @queue end |
#recipients ⇒ Object (readonly)
Returns the value of attribute recipients.
31 32 33 |
# File 'lib/postjob/job.rb', line 31 def recipients @recipients end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
27 28 29 |
# File 'lib/postjob/job.rb', line 27 def results @results end |
#root_id ⇒ Object (readonly)
Returns the value of attribute root_id.
15 16 17 |
# File 'lib/postjob/job.rb', line 15 def root_id @root_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
26 27 28 |
# File 'lib/postjob/job.rb', line 26 def status @status end |
#sticky_host_id ⇒ Object (readonly)
Returns the value of attribute sticky_host_id.
36 37 38 |
# File 'lib/postjob/job.rb', line 36 def sticky_host_id @sticky_host_id end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
33 34 35 |
# File 'lib/postjob/job.rb', line 33 def @tags end |
#timed_out ⇒ Object (readonly)
Returns the value of attribute timed_out.
32 33 34 |
# File 'lib/postjob/job.rb', line 32 def timed_out @timed_out end |
#timing_out_at ⇒ Object (readonly)
Returns the value of attribute timing_out_at.
23 24 25 |
# File 'lib/postjob/job.rb', line 23 def timing_out_at @timing_out_at end |
#workflow ⇒ Object (readonly)
Returns the value of attribute workflow.
18 19 20 |
# File 'lib/postjob/job.rb', line 18 def workflow @workflow end |
#workflow_method ⇒ Object (readonly)
Returns the value of attribute workflow_method.
19 20 21 |
# File 'lib/postjob/job.rb', line 19 def workflow_method @workflow_method end |
#workflow_version ⇒ Object (readonly)
Returns the value of attribute workflow_version.
20 21 22 |
# File 'lib/postjob/job.rb', line 20 def workflow_version @workflow_version end |
Class Method Details
Instance Method Details
#resolve ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/postjob/job.rb', line 40 def resolve expect! status => STATUSES case status when "ok" then result when "ready" then :pending when "processing" then :pending when "sleep" then :pending when "timeout" then raise Timeout::Error when "err" then :pending when "failed" then raise Postjob::Error::Nonrecoverable, self end end |
#resolved? ⇒ Boolean
54 55 56 57 |
# File 'lib/postjob/job.rb', line 54 def resolved? expect! status => STATUSES %w(ok timeout failed).include?(status) end |
#result ⇒ Object
59 60 61 |
# File 'lib/postjob/job.rb', line 59 def result results && results.first end |
#to_s ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/postjob/job.rb', line 63 def to_s full_workflow = workflow full_workflow += "@#{workflow_version}" if workflow_version != "" full_workflow += ".#{workflow_method}" if workflow_method != "run" args = (self.args || []).map(&:inspect).join(", ") "Postjob##{full_id}: #{full_workflow}(#{args}) (#{status})" end |