Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass item in after_unlock callback #665

Merged

Conversation

piloos
Copy link
Contributor

@piloos piloos commented Dec 1, 2021

Suggestion to pass item in after_unlock callback.

Loosely related to issue #664

@@ -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...

@mhenrixon mhenrixon merged commit bac1f67 into mhenrixon:main Dec 2, 2021
@piloos piloos deleted the pass_item_in_after_unlock_callback branch February 21, 2023 16:05
@jonasva jonasva restored the pass_item_in_after_unlock_callback branch March 3, 2023 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants