Sha256: da7120afdb34d3aca077b7f93bb92c510b149e90c4ca5e5acb41457d6cc2e1c7

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 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?
        good_job.perform
        good_job.advisory_unlock
      end

      good_job
    end

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

    private

    def inline?
      @inline
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
good_job-0.4.0 lib/good_job/adapter.rb
good_job-0.3.0 lib/good_job/adapter.rb