Sha256: 0d3785dcc8b3a694a89a192b6dca50578d2a0d2d6f5005b8c547be6976b31da5

Contents?: true

Size: 926 Bytes

Versions: 2

Compression:

Stored size: 926 Bytes

Contents

module ActiveJob
  module QueueAdapters
    #   Rails.application.config.active_job.queue_adapter = :beaneater
    class ActiveBeaneaterAdapter

      class << self
        def enqueue(job) #:nodoc:
          enqueue_at(job, nil)
        end

        def enqueue_at(job, timestamp) #:nodoc:
          delay = timestamp ? timestamp - Time.current.to_f : 0

          tube = client.tubes[ActiveBeaneater.resolve_queue_name(job.queue_name)]

          pri = job.respond_to?(:queue_priority_number) ?
            job.queue_priority_number : 0

          ttr = job.respond_to?(:queue_respond_timeout) ?
            job.queue_respond_timeout : 10.minutes

          tube.put(job.serialize.to_json,
                   delay: delay,
                   pri: pri,
                   ttr: ttr)
        end

        private

        def client
          Rails.application.config.beaneater.client
        end

      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_beaneater-0.1.1 lib/active_job/queue_adapters/active_beaneater_adapter.rb
active_beaneater-0.1.0 lib/active_job/queue_adapters/active_beaneater_adapter.rb