Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def worker_class
def after_unlock_hook
lambda do
if @worker_class.respond_to?(:after_unlock)
@worker_class.after_unlock # instance method in sidekiq v6
@worker_class.after_unlock(item) # instance method in sidekiq v6
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the suggestion, in this case we would likely have to check the arity of the method and only pass the item if the callback method responds to 1 method argument and warn if it does not.

This would otherwise crash for a lot of users if the method doesn't support an argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I wasn't aware of the arity check possibility. I added it.
The PR is blocked on a code climate issue. Breaking up the method seems to add more complexity...

elsif worker_class.respond_to?(:after_unlock)
worker_class.after_unlock # class method regardless of sidekiq version
worker_class.after_unlock(item) # class method regardless of sidekiq version
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/workers/until_executed_2_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def perform(one, two)
[one, two]
end

def after_unlock
def after_unlock(item)
# NO OP
end
end
2 changes: 1 addition & 1 deletion spec/support/workers/until_executed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def perform(one, two = nil)
[one, two]
end

def after_unlock
def after_unlock(item)
# NO OP
end
end