aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_job/queue_adapters/sidekiq_adapter.rb
blob: c8fac3296373eb659be79757c6983a823958f3d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'sidekiq'

module ActiveJob
  module QueueAdapters
    class SidekiqAdapter
      class << self
        def queue(job, *args)
          JobWrapper.client_push class: JobWrapper, queue: job.queue_name, args: [ job, *args ]
        end
      end

      class JobWrapper
        include Sidekiq::Worker

        def perform(job_name, *args)
          job_name.constantize.new.perform *Parameters.deserialize(args)
        end
      end
    end
  end
end