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

Respect sidekiq_options overridden by .set #27

Merged

Conversation

stevenharman
Copy link
Contributor

Sidekiq provides a Sidekiq::Job.set(…) API which can override sidekiq_options set at the class level, on a job-by-job instance basis. Sidekiq does the work of merging the options from set with those from the class-level sidekiq_options, into the "job" (really a normalized hash) that's handed to the middleware. So if we first look there for any debounce: options, rather than going to the klass.get_sidekiq_options, we can respect any overrides from the .set API.

In this commit I left the klass.get_sidekiq_options as a fallback, though I'm not sure that's actually necessary.

NOTE: This Sidekiq does not (currently?) deeply-merged nested options.
I've asked about this elsewhere: sidekiq/sidekiq#6366

@kukicola
Copy link
Collaborator

Hello, we are currently testing v3 version of the gem with completely rewritten code, it should be released pretty soon. I'll make sure to include this fix in the release

@stevenharman
Copy link
Contributor Author

Hi @kukicola. I saw the re-write underway, and this code should fit there as well since it's only to do with how the job's options are fetched, and not really anything to do with the debouncing machinery. If there's a stable branch for v3, I can open a PR targeting that branch too.

@kukicola
Copy link
Collaborator

@stevenharman sorry for the very delayed response. v3 branch has been merged to the master, can you rebase?

Sidekiq provides a `Sidekiq::Job.set(…)` API which can override
`sidekiq_options` set at the class level, on a job-by-job instance
basis. Sidekiq does the work of merging the options from `set` with
those from the class-level `sidekiq_options`, into the
"job" (really a normalized hash) that's handed to the middleware. So if
we first look there for any `debounce:` options, rather than going to
the `klass.get_sidekiq_options`, we can respect any overrides from the
`.set` API.

In this commit I left the `klass.get_sidekiq_options` as a fallback,
though I'm not sure that's actually necessary.

NOTE: This Sidekiq does not (currently?) deeply-merged nested options.
I've asked about this elsewhere: sidekiq/sidekiq#6366
This removes two of the deprecated usages of `.debounce` in favor of
`.perform_async`. It also adds an assertion for the one place we want to
call the deprecated method, making sure we emit the warning message.
@stevenharman
Copy link
Contributor Author

@kukicola rebased, and included another commit to fix some deprecations in the tests.

@kukicola kukicola merged commit 8b27d16 into paladinsoftware:master Oct 22, 2024
@stevenharman stevenharman deleted the respect_set_option_overrides branch October 22, 2024 16:41
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.

2 participants