2012-01-25 13:32:51 -08:00
|
|
|
require 'sidekiq/client'
|
2012-01-23 14:05:03 -08:00
|
|
|
|
2012-01-16 20:05:38 -08:00
|
|
|
module Sidekiq
|
|
|
|
|
2012-01-25 13:32:51 -08:00
|
|
|
##
|
|
|
|
# Include this module in your worker class and you can easily create
|
|
|
|
# asynchronous jobs:
|
|
|
|
#
|
|
|
|
# class HardWorker
|
|
|
|
# include Sidekiq::Worker
|
|
|
|
#
|
|
|
|
# def perform(*args)
|
|
|
|
# # do some work
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# Then in your Rails app, you can do this:
|
|
|
|
#
|
|
|
|
# HardWorker.perform_async(1, 2, 3)
|
|
|
|
#
|
|
|
|
# Note that perform_async is a class method, perform is an instance method.
|
|
|
|
module Worker
|
|
|
|
extend self
|
2012-01-21 16:42:21 -08:00
|
|
|
|
2012-01-25 13:32:51 -08:00
|
|
|
def perform_async(*args)
|
|
|
|
Sidekiq::Client.enqueue('class' => self.name, 'args' => args)
|
2012-01-16 20:05:38 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|