module Sidekiq::Job

Include this module in your job class and you can easily create asynchronous jobs:

class HardJob
  include Sidekiq::Job
  sidekiq_options queue: 'critical', retry: 5

  def perform(*args)
    # do some work
  end
end

Then in your Rails app, you can do this:

HardJob.perform_async(1, 2, 3)

Note that perform_async is a class method, perform is an instance method.

Sidekiq::Job also includes several APIs to provide compatibility with ActiveJob.

class SomeJob
  include Sidekiq::Job
  queue_as :critical

  def perform(...)
  end
end

SomeJob.set(wait_until: 1.hour).perform_async(123)

Note that arguments passed to the job must still obey Sidekiq’s best practice for simple, JSON-native data types. Sidekiq will not implement ActiveJob’s more complex argument serialization. For this reason, we don’t implement ‘perform_later` as our call semantics are very different.