Sha256: d81f285c4d8a99d482880bd87c9fa758f3694368e242ac4188c2b068aa827ad2

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

module QueueBus
  module Adapters
    class Sidekiq < QueueBus::Adapters::Base
      def enabled!
        # know we are using it
        require 'sidekiq'

        #this sidekiq middleware adds in the 'retry' key to the job payload so we ensure sidekiq plays well with resque
        ::Sidekiq.configure_server do |config|
          config.client_middleware do |chain|
            chain.prepend ::SidekiqBus::Middleware::Client::Retry
          end
        end
        ::QueueBus::Worker.include ::Sidekiq::Worker
      end

      def redis(&block)
        ::Sidekiq.redis(&block)
      end

      def enqueue(queue_name, klass, hash)
        ::Sidekiq::Client.push('queue' => queue_name, 'class' => klass, 'args' => [hash])
      end

      def enqueue_at(epoch_seconds, queue_name, klass, hash)
        ::Sidekiq::Client.push('queue' => queue_name, 'class' => klass, 'args' => [hash], 'at' => epoch_seconds)
      end

      def setup_heartbeat!(queue_name)
        # TODO: not sure how to do this or what is means to set this up in Sidekiq
        raise NotImplementedError
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sidekiq-bus-0.7.0 lib/sidekiq_bus/adapter.rb
sidekiq-bus-0.6.3 lib/sidekiq_bus/adapter.rb
sidekiq-bus-0.6.2 lib/sidekiq_bus/adapter.rb
sidekiq-bus-0.6.1 lib/sidekiq_bus/adapter.rb
sidekiq-bus-0.6.0 lib/sidekiq_bus/adapter.rb
sidekiq-bus-0.5.10 lib/sidekiq_bus/adapter.rb
sidekiq-bus-0.5.9 lib/sidekiq_bus/adapter.rb