Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanety/delayed_job_bulk
https://github.com/kanety/delayed_job_bulk
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanety/delayed_job_bulk
- Owner: kanety
- License: mit
- Created: 2023-05-03T09:02:38.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-21T00:43:07.000Z (3 months ago)
- Last Synced: 2024-10-21T04:07:15.661Z (3 months ago)
- Language: Ruby
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DelayedJobBulk
Bulk insert many jobs at once for delayed_job.
## Dependencies
* ruby 2.7+
* activerecord 6.0+
* delayed_job 4.1
* delayed_job_active_record 4.1## Installation
Add this line to your application's Gemfile:
```ruby
gem 'delayed_job_bulk'
```And then execute:
$ bundle
## Usage
Build `ActiveJob::Base` instances and pass them to `Delayed::Job::Bulk.enqueue`:
```ruby
class SampleJob < ActiveJob::Base
endactive_jobs = 10.times.map { SampleJob.new('sample') }
jobs = Delayed::Job::Bulk.enqueue(active_jobs)
```Return value of `Delayed::Job::Bulk.enqueue` is an array of Delayed::Job instance:
```ruby
jobs.size #=> 10
jobs.each do |job|
job.id #=> 12345 (id is set only postgresql)
end
```### Caveats
Callbacks related with ActiveJob (`before_enqueue`, `after_enqueue` and `around_enqueue`) are not called for bulk enqueue.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/kanety/delayed_job_bulk.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).