lib/gush/job.rb in gush-3.0.0 vs lib/gush/job.rb in gush-4.0.0

- old
+ new

@@ -1,11 +1,11 @@ module Gush class Job attr_accessor :workflow_id, :incoming, :outgoing, :params, - :finished_at, :failed_at, :started_at, :enqueued_at, :payloads, - :klass, :queue, :wait - attr_reader :id, :klass, :output_payload, :params + :finished_at, :failed_at, :started_at, :enqueued_at, :payloads, + :klass, :queue, :wait + attr_reader :id, :output_payload def initialize(opts = {}) options = opts.dup assign_variables(options) end @@ -21,11 +21,12 @@ enqueued_at: enqueued_at, started_at: started_at, failed_at: failed_at, params: params, workflow_id: workflow_id, - output_payload: output_payload + output_payload: output_payload, + wait: wait } end def name @name ||= "#{klass}|#{id}" @@ -54,9 +55,17 @@ def enqueue! @enqueued_at = current_timestamp @started_at = nil @finished_at = nil @failed_at = nil + end + + def enqueue_worker!(options = {}) + Gush::Worker.set(options).perform_later(workflow_id, name) + end + + def worker_options + { queue: queue, wait: wait }.compact end def finish! @finished_at = current_timestamp end