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

Add sidekiq's perform_bulk method signature #172

Closed
wants to merge 2 commits into from

Conversation

leeourand
Copy link

Type of Change

  • Add RBI for a new gem
  • Modify RBI for an existing gem
  • Other:

Changes

@leeourand
Copy link
Author

I have signed the CLA!

@@ -75,6 +75,9 @@ module Sidekiq::Job::ClassMethods

sig { params(interval: T.untyped, args: T.untyped).returns(String) }
def perform_in(interval, *args); end

sig { params(args: T.untyped, kwargs: T.untyped).returns(String) }
def perform_bulk(*args, **kwargs); end
Copy link
Member

Choose a reason for hiding this comment

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

The perform_bulk method in Job indeed accepts **kwargs, but under the hood it invokes Setter#perform_bulk, which only accepts batch_size.

Can you actually invoke this method with any keyword arguments that aren't batch_size? If not, maybe it's worth making it explicit.

Copy link
Author

Choose a reason for hiding this comment

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

Good point! I've updated the PR. Forgive me, I'm still a bit of a sorbet noob, so there might be a better way of doing this. But this seems to do the trick.

Copy link
Member

Choose a reason for hiding this comment

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

This is actually telling Sorbet to accept keyword arguments and that each one of them will be a { batch_size: Integer } shape. To get it to accept only batch_size, you need to do

sig { params(args: T.untyped, batch_size: Integer).returns(String) }
def perform_bulk(*args, batch_size: 1000); end

@leeourand leeourand closed this Aug 16, 2023
@Morriar Morriar added the rbi Change related to RBI annotations label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rbi Change related to RBI annotations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants