1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Rejigger resque helpers to remove perform_in_queue

This commit is contained in:
Mike Perham 2012-09-07 08:35:27 -07:00
parent a270fd8dc1
commit be84d53c7f
2 changed files with 7 additions and 11 deletions

View file

@ -65,22 +65,22 @@ module Sidekiq
pushed ? item['jid'] : nil pushed ? item['jid'] : nil
end end
# Resque compatibility helpers. # Resque compatibility helpers.
# #
# Example usage: # Example usage:
# Sidekiq::Client.enqueue(MyWorker, 'foo', 1, :bat => 'bar') # Sidekiq::Client.enqueue(MyWorker, 'foo', 1, :bat => 'bar')
# #
# Messages are enqueued to the 'default' queue. # Messages are enqueued to the 'default' queue.
# #
def self.enqueue(klass, *args) def self.enqueue(klass, *args)
klass.perform_async(*args) klass.client_push('class' => self, 'args' => args)
end end
# Example usage: # Example usage:
# Sidekiq::Client.enqueue_to(:queue_name, MyWorker, 'foo', 1, :bat => 'bar') # Sidekiq::Client.enqueue_to(:queue_name, MyWorker, 'foo', 1, :bat => 'bar')
# #
def self.enqueue_to(queue, klass, *args) def self.enqueue_to(queue, klass, *args)
klass.perform_in_queue(queue, *args) klass.client_push('queue' => queue, 'class' => self, 'args' => args)
end end
end end
end end

View file

@ -35,10 +35,6 @@ module Sidekiq
client_push('class' => self, 'args' => args) client_push('class' => self, 'args' => args)
end end
def perform_in_queue(queue, *args)
client_push('queue' => queue, 'class' => self, 'args' => args)
end
def perform_in(interval, *args) def perform_in(interval, *args)
int = interval.to_f int = interval.to_f
ts = (int < 1_000_000_000 ? Time.now.to_f + int : int) ts = (int < 1_000_000_000 ? Time.now.to_f + int : int)