Skip to content

Use Sidekiq's API directly (part 1 of 3)#6725

Open
thomasleese wants to merge 3 commits intopds-cascading-job-stringsfrom
use-sidekiq-directly-1
Open

Use Sidekiq's API directly (part 1 of 3)#6725
thomasleese wants to merge 3 commits intopds-cascading-job-stringsfrom
use-sidekiq-directly-1

Conversation

@thomasleese
Copy link
Copy Markdown
Contributor

@thomasleese thomasleese commented Apr 29, 2026

This is an under the hood refactor that changes how we queue background jobs to use the Sidekiq API directly, rather than going via Active Job.

We're currently doing a mix of both, and we should standardise on a single approach. We have to use the Sidekiq API for rate limiting, unique jobs and bulk enqueuing, therefore we should standardise on using it everywhere.

To ensure no jobs are lost while this is deployed, we need to split this change in to three parts. This first part:

  • Converts any jobs with no arguments straight to Sidekiq as these are safe to re-run
  • Adds Sidekiq versions of any jobs that accept arguments and queues them instead of the ActiveJob versions

Depends on #6738

Jira Issue - MAV-7288

@thomasleese thomasleese added this to the v8.4.0 milestone Apr 29, 2026
@thomasleese thomasleese added the refactor Improving maintainability label Apr 29, 2026
@thomasleese thomasleese force-pushed the use-sidekiq-directly-1 branch 5 times, most recently from 3faefa4 to ece3423 Compare April 30, 2026 09:12
@thomasleese thomasleese changed the base branch from next to refactor-application-job April 30, 2026 09:35
Base automatically changed from refactor-application-job to next April 30, 2026 10:54
@thomasleese thomasleese force-pushed the use-sidekiq-directly-1 branch 6 times, most recently from fd3bd16 to 52db5ba Compare April 30, 2026 13:43
This converts any of the jobs which take no arguments (and are likely
queued on a schedule) to Sidekiq. Jobs without arguments are easier to
convert to Sidekiq as there's no need to handle the argument
serialisation and deserialisation, therefore we can switch these jobs
directly.

For `GIASImportJob`, I've removed the `dry_run` parameter as we were
never setting this to true. If we needed to run this in a console, we
can run the steps manually.

Jira-Issue: MAV-7288
This adds Sidekiq-only versions of the `EmailDeliveryJob`,
`SMSDeliveryJob` and `NotifyDeliveryJob` jobs, to support the migration
to using Sidekiq directly.

Using Sidekiq directly doesn't support named parameters in jobs, so we
now have to pass a JSON-serializable hash containing the parameters that
are passed to the `GovukNotifyPersonalisation` class. I'd like to
refactor this further to add safeguards to ensure the right keys are
used, but for now I didn't want to change too much here.

Jira-Issue: MAV-7288
This converts the remaining ActiveJob jobs to be Sidekiq-only. These
jobs all accept arguments, meaning we need to be careful about the
serialisation and deserialisation of the arguments.

To ensure the migration doesn't result in any missed jobs, this commit
adds Sidekiq-only versions of all the jobs which are queued instead of
the ActiveJob ones. Any ActiveJob jobs left in the queue will continue
to execute.

Jira-Issue: MAV-7288
@thomasleese thomasleese force-pushed the use-sidekiq-directly-1 branch from 52db5ba to f377964 Compare April 30, 2026 13:46
@thomasleese thomasleese marked this pull request as ready for review April 30, 2026 13:59
@thomasleese thomasleese requested a review from a team as a code owner April 30, 2026 13:59
@thomasleese thomasleese changed the base branch from next to pds-cascading-job-strings April 30, 2026 21:43
Copy link
Copy Markdown
Contributor

@jhenderson jhenderson left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Improving maintainability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants