Sha256: a700c9f16eae350615dac73950f6c83f698513dfde357b34032d04adc909f31d

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 Bytes

Contents

# typed: true

module UpGush
  module Jobs
    class ResumeWorkflow
      include Sidekiq::Worker
      extend T::Sig

      sidekiq_options lock: :until_executed, on_conflict: :reject
      sidekiq_options queue: :critical

      attr_reader :workflow_id, :job_id, :job_params, :job

      def perform(workflow_id, job_id, job_params = {})
        @workflow_id = workflow_id
        @job_id = job_id
        @job_params = job_params

        find_job

        if job
          if job.paused?
            job.params = job_params
            job.resume!
          end
        else
          UpGush::Logger.log.warn("UpGush::Jobs::ResumeWorkflow => Job #{job_id} not found for workflow #{workflow_id}!")
        end
      rescue Gush::WorkflowNotFound => e
        UpGush::Logger.log.warn("UpGush::Jobs::ResumeWorkflow => #{e.message}")
      end

      private

      def find_job
        wf = Gush::Workflow.find(workflow_id)
        @job ||= wf.jobs.find { |j| j.id == job_id }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
up_gush-3.0.0.1 lib/up_gush/jobs/resume_workflow.rb