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 bulk enqueue support to ActiveJob adapter #422

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dtcristo
Copy link
Contributor

@dtcristo dtcristo commented Mar 6, 2024

Built on top of #420, merge that first.

When using ActiveJob, you can now enqueue jobs in bulk using either Que.bulk_enqueue:

Que.bulk_enqueue do
  TestJobClass.perform_later(1, 2)
  OtherTestJobClass.set(wait: 1.minute, queue: 'custom', priority: 200).perform_later(3, 4)
end

Or when running Rails >= 7.1 using ActiveJob.perform_all_later:

ActiveJob.perform_all_later([
  TestJobClass.new(1, 2),
  OtherTestJobClass.new(3, 4).set(wait: 1.minute, queue: 'custom', priority: 200),
])

[Bundler 2.5 dropped support for Ruby 2.7](https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.0).
Since we are testing with Ruby 2.7, we should pin the version of Bundler
to 2.4.x since this is the last version that's compatible with 2.7.
Prepare spec for bulk enqueue refactor to support bulk enqueue of jobs
with differing job class and job options.
Allow bulk enqueue of multiple different job classes and differing job
options in a single `.bulk_enqueue` block. Each job can now differ by
job class, queue, priority, run at and tags (in addition to args and
kwargs).
When using ActiveJob, you can now enqueue jobs in bulk using either
`Que.bulk_enqueue`:
```ruby
Que.bulk_enqueue do
    TestJobClass.perform_later(1, 2)
    OtherTestJobClass.set(wait: 1.minute, queue: 'custom', priority: 200).perform_later(3, 4)
end
```

Or when running Rails >= 7.1 using `ActiveJob.perform_all_later`:
```ruby
ActiveJob.perform_all_later([
    TestJobClass.new(1, 2),
    OtherTestJobClass.new(3, 4).set(wait: 1.minute, queue: 'custom', priority: 200),
])
```
@dtcristo dtcristo force-pushed the dtcristo/active-job-enqueue-all branch from 890981f to 691dd68 Compare March 6, 2024 02:44
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.

1 participant