Last active
August 29, 2015 14:21
-
-
Save robvolk/89f22d8cf251cfe7c30b to your computer and use it in GitHub Desktop.
Perform Sidekiq jobs async on any queue!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HackTheWorld | |
include Sidekiq::Worker | |
include Sidekiq::AnyQueue | |
def perform(arg1, arg2) | |
// ... | |
end | |
end | |
HackTheWorld.perform_async_on_queue(:fast, "arg1", "arg2") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sidekiq | |
module AnyQueue | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def perform_async_on_queue(queue, *args) | |
Sidekiq::Client.push({ | |
'class' => self, | |
'queue' => queue, | |
'args' => args | |
}) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment