Sha256: 83a918e4d2a8a0fe8d3deeab7ac7500c9444ddfbd7e4ae55268dd3f33363868b

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

module GoodJob
  class Adapter
    def initialize(inline: false)
      @inline = inline
    end

    def enqueue(active_job)
      enqueue_at(active_job, nil)
    end

    def enqueue_at(active_job, timestamp)
      good_job = GoodJob::Job.enqueue(
        active_job,
        scheduled_at: timestamp ? Time.at(timestamp) : nil,
        create_with_advisory_lock: inline?
      )

      if inline?
        begin
          good_job.perform
        ensure
          good_job.advisory_unlock
        end
      end

      good_job
    end

    def shutdown(wait: true) # rubocop:disable Lint/UnusedMethodArgument
      nil
    end

    def inline?
      @inline
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
good_job-0.6.0 lib/good_job/adapter.rb