Class: Gush::Job
- Inherits:
-
Object
- Object
- Gush::Job
- Defined in:
- lib/gush/job.rb
Instance Attribute Summary collapse
-
#enqueued_at ⇒ Object
Returns the value of attribute enqueued_at.
-
#failed_at ⇒ Object
Returns the value of attribute failed_at.
-
#finished_at ⇒ Object
Returns the value of attribute finished_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#incoming ⇒ Object
Returns the value of attribute incoming.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#outgoing ⇒ Object
Returns the value of attribute outgoing.
-
#output_payload ⇒ Object
readonly
Returns the value of attribute output_payload.
-
#params ⇒ Object
Returns the value of attribute params.
-
#payloads ⇒ Object
Returns the value of attribute payloads.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
-
#workflow_id ⇒ Object
Returns the value of attribute workflow_id.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #enqueue! ⇒ Object
- #enqueued? ⇒ Boolean
- #fail! ⇒ Object
- #failed? ⇒ Boolean
- #finish! ⇒ Object
- #finished? ⇒ Boolean
- #has_no_dependencies? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Job
constructor
A new instance of Job.
- #name ⇒ Object
- #output(data) ⇒ Object
- #parents_succeeded? ⇒ Boolean
- #perform ⇒ Object
- #ready_to_start? ⇒ Boolean
- #running? ⇒ Boolean
- #start! ⇒ Object
- #started? ⇒ Boolean
- #succeeded? ⇒ Boolean
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Job
Returns a new instance of Job.
7 8 9 10 |
# File 'lib/gush/job.rb', line 7 def initialize(opts = {}) = opts.dup assign_variables() end |
Instance Attribute Details
#enqueued_at ⇒ Object
Returns the value of attribute enqueued_at.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def enqueued_at @enqueued_at end |
#failed_at ⇒ Object
Returns the value of attribute failed_at.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def failed_at @failed_at end |
#finished_at ⇒ Object
Returns the value of attribute finished_at.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def finished_at @finished_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/gush/job.rb', line 5 def id @id end |
#incoming ⇒ Object
Returns the value of attribute incoming.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def incoming @incoming end |
#klass ⇒ Object
Returns the value of attribute klass.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def klass @klass end |
#outgoing ⇒ Object
Returns the value of attribute outgoing.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def outgoing @outgoing end |
#output_payload ⇒ Object (readonly)
Returns the value of attribute output_payload.
5 6 7 |
# File 'lib/gush/job.rb', line 5 def output_payload @output_payload end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def params @params end |
#payloads ⇒ Object
Returns the value of attribute payloads.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def payloads @payloads end |
#queue ⇒ Object
Returns the value of attribute queue.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def queue @queue end |
#started_at ⇒ Object
Returns the value of attribute started_at.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def started_at @started_at end |
#workflow_id ⇒ Object
Returns the value of attribute workflow_id.
3 4 5 |
# File 'lib/gush/job.rb', line 3 def workflow_id @workflow_id end |
Class Method Details
.from_hash(hash) ⇒ Object
37 38 39 |
# File 'lib/gush/job.rb', line 37 def self.from_hash(hash) hash[:klass].constantize.new(hash) end |
Instance Method Details
#as_json ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gush/job.rb', line 12 def as_json { id: id, klass: klass.to_s, queue: queue, incoming: incoming, outgoing: outgoing, finished_at: finished_at, enqueued_at: enqueued_at, started_at: started_at, failed_at: failed_at, params: params, workflow_id: workflow_id, output_payload: output_payload } end |
#enqueue! ⇒ Object
52 53 54 55 56 57 |
# File 'lib/gush/job.rb', line 52 def enqueue! @enqueued_at = @started_at = nil @finished_at = nil @failed_at = nil end |
#enqueued? ⇒ Boolean
67 68 69 |
# File 'lib/gush/job.rb', line 67 def enqueued? !enqueued_at.nil? end |
#fail! ⇒ Object
63 64 65 |
# File 'lib/gush/job.rb', line 63 def fail! @finished_at = @failed_at = end |
#failed? ⇒ Boolean
75 76 77 |
# File 'lib/gush/job.rb', line 75 def failed? !failed_at.nil? end |
#finish! ⇒ Object
59 60 61 |
# File 'lib/gush/job.rb', line 59 def finish! @finished_at = end |
#finished? ⇒ Boolean
71 72 73 |
# File 'lib/gush/job.rb', line 71 def finished? !finished_at.nil? end |
#has_no_dependencies? ⇒ Boolean
101 102 103 |
# File 'lib/gush/job.rb', line 101 def has_no_dependencies? incoming.empty? end |
#name ⇒ Object
29 30 31 |
# File 'lib/gush/job.rb', line 29 def name @name ||= "#{klass}|#{id}" end |
#output(data) ⇒ Object
41 42 43 |
# File 'lib/gush/job.rb', line 41 def output(data) @output_payload = data end |
#parents_succeeded? ⇒ Boolean
95 96 97 98 99 |
# File 'lib/gush/job.rb', line 95 def parents_succeeded? !incoming.any? do |name| !client.find_job(workflow_id, name).succeeded? end end |
#perform ⇒ Object
45 46 |
# File 'lib/gush/job.rb', line 45 def perform end |
#ready_to_start? ⇒ Boolean
91 92 93 |
# File 'lib/gush/job.rb', line 91 def ready_to_start? !running? && !enqueued? && !finished? && !failed? && parents_succeeded? end |
#running? ⇒ Boolean
87 88 89 |
# File 'lib/gush/job.rb', line 87 def running? started? && !finished? end |
#start! ⇒ Object
48 49 50 |
# File 'lib/gush/job.rb', line 48 def start! @started_at = end |
#started? ⇒ Boolean
83 84 85 |
# File 'lib/gush/job.rb', line 83 def started? !started_at.nil? end |
#succeeded? ⇒ Boolean
79 80 81 |
# File 'lib/gush/job.rb', line 79 def succeeded? finished? && !failed? end |