Skip to content

Commit

Permalink
Don't allow delay usage on Sidekiq::Worker
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Oct 12, 2015
1 parent f277cae commit 242109e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lib/sidekiq/worker.rb
Expand Up @@ -38,6 +38,18 @@ def logger

module ClassMethods

def delay(*args)
raise ArgumentError, "Do not call .delay on a Sidekiq::Worker class, call .perform_async"
end

def delay_for(*args)
raise ArgumentError, "Do not call .delay_for on a Sidekiq::Worker class, call .perform_in"
end

def delay_until(*args)
raise ArgumentError, "Do not call .delay_until on a Sidekiq::Worker class, call .perform_at"
end

def perform_async(*args)
client_push('class' => self, 'args' => args)
end
Expand Down
4 changes: 2 additions & 2 deletions test/test_api.rb
Expand Up @@ -202,10 +202,10 @@ class ApiWorker
end

it 'unwraps delayed jobs' do
ApiWorker.delay.foo(1,2,3)
Sidekiq::Queue.delay.foo(1,2,3)
q = Sidekiq::Queue.new
x = q.first
assert_equal "TestApi::ApiWorker.foo", x.display_class
assert_equal "Sidekiq::Queue.foo", x.display_class
assert_equal [1,2,3], x.display_args
end

Expand Down

0 comments on commit 242109e

Please sign in to comment.