Sha256: 16192fb3a1717d24781998096edb1d54d8722f5d0dcbbfb96ce5bd05f0674206

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module Sidejobs
  module Extensions
    module ActiveJob
      module QueueAdapters
        class SidejobsAdapter
          class << self

            def enqueue(job)
              Sidejobs.queue.add(
                job.serialize,
                queue: job.queue_name,
                priority: calculate_priority(job.queue_name)
              )
            end

            def enqueue_at(job, timestamp)
              Sidejobs.queue.add(
                job.serialize,
                queue: job.queue_name,
                priority: calculate_priority(job.queue_name),
                schedule_at: Time.at(timestamp)
              )
            end

            private

            def calculate_priority(queue)
              case queue
              when 'mailers'
                80
              when 'high_priority'
                60
              when 'default'
                40
              when 'low_priority'
                20
              else
                0
              end
            end

          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidejobs-4.0.0.2 lib/sidejobs/extensions/active_job/queue_adapter.rb
sidejobs-4.0.0.1 lib/sidejobs/extensions/active_job/queue_adapter.rb
sidejobs-4.0.0.0 lib/sidejobs/extensions/active_job/queue_adapter.rb
sidejobs-0.0.1 lib/sidejobs/extensions/active_job/queue_adapter.rb