Sha256: b258155402c400a73017e5377d9845ee205b0d52bdf73c7ff395f92cdbda6e6a

Contents?: true

Size: 856 Bytes

Versions: 10

Compression:

Stored size: 856 Bytes

Contents

# FIXME: Abstract worker (see ActiveJob)
require 'sidekiq'
module DirtyPipeline
  class Worker
    include Sidekiq::Worker
    using StringCamelcase

    # args should contain - "enqueued_pipeline"
    # args should contain - some args to find_subject
    # args should contain - some args to make transition
    def perform(options = {})
      pipeline_klass =
        Kernel.const_get(options.fetch("enqueued_pipeline").to_s.camelcase)
      subject = pipeline_klass.find_subject(*options.fetch("find_subject_args"))
      transaction_id = options.fetch("transaction_id")
      pipeline = pipeline_klass.new(subject, uuid: transaction_id)
      operation = options.fetch("operation")

      case operation
      when "cleanup"
        return pipeline.clean
      when "retry"
        return pipeline.retry
      end
      pipeline.call
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dirty_pipeline-0.9.0 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.8.3 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.8.2 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.8.1 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.7.1 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.7.0 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.6.4 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.6.3 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.6.2 lib/dirty_pipeline/worker.rb
dirty_pipeline-0.6.1 lib/dirty_pipeline/worker.rb