mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Added another Resque compatibility helper #enqueue_to
This commit is contained in:
parent
169cdea2c8
commit
571e287f1b
2 changed files with 15 additions and 2 deletions
|
@ -61,14 +61,22 @@ module Sidekiq
|
|||
!! pushed
|
||||
end
|
||||
|
||||
# Redis compatibility helper. Example usage:
|
||||
# Resque compatibility helpers.
|
||||
#
|
||||
# Sidekiq::Client.enqueue(MyWorker, 'foo', 1, :bat => 'bar')
|
||||
# Example usage:
|
||||
# Sidekiq::Client.enqueue(MyWorker, 'foo', 1, :bat => 'bar')
|
||||
#
|
||||
# Messages are enqueued to the 'default' queue.
|
||||
#
|
||||
def self.enqueue(klass, *args)
|
||||
klass.perform_async(*args)
|
||||
end
|
||||
|
||||
# Example usage:
|
||||
# Sidekiq::Client.enqueue_to(:queue_name, MyWorker, 'foo', 1, :bat => 'bar')
|
||||
#
|
||||
def self.enqueue_to(queue, klass, *args)
|
||||
klass.perform_in_queue(queue, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,6 +35,11 @@ module Sidekiq
|
|||
client_push('class' => self, 'args' => args)
|
||||
end
|
||||
|
||||
def perform_in_queue(queue, *args)
|
||||
client_push('queue' => queue, 'class' => self, 'args' => args)
|
||||
end
|
||||
alias_method :perform_at_queue, :perform_in_queue
|
||||
|
||||
def perform_in(interval, *args)
|
||||
int = interval.to_f
|
||||
ts = (int < 1_000_000_000 ? Time.now.to_f + int : int)
|
||||
|
|
Loading…
Add table
Reference in a new issue