Skip to content

Commit 13869ec

Browse files
authored
Update README.md
1 parent fdbce76 commit 13869ec

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

+41-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ The Delayed Job adapter will be [removed from Rails soon](https://github.com/rai
88

99
If you are using a version of Rails that includes a Delayed Job adapter, using this gem will replace Rails' version with this gem's.
1010

11-
This gem implements some new features beyond what the Rails adapter did:
11+
This gem implements some new features beyond what the Rails adapter did. See [features](#features) for instructions.
1212

1313
- Support for [`perform_all_later`](https://github.com/rails/rails/pull/46603).
14-
- You can set `run_at` directly on a job instance.
14+
- You can set `run_at` when bulk enqueueing.
1515
- You can persist extra attributes on a job by writing to `job_attributes`.
1616

1717
---
1818

1919
- [Quick start](#quick-start)
20+
- [Features](#features)
2021
- [Support](#support)
2122
- [License](#license)
2223
- [Contribution guide](#contribution-guide)
@@ -34,6 +35,44 @@ Configure the Active Job backend. [See the Rails docs for more information](http
3435
config.active_job.queue_adapter = :delayed_job
3536
```
3637

38+
## Features
39+
40+
This gem supports all the base functionality of any Active Job adapter. So anything in https://guides.rubyonrails.org/active_job_basics.html should work. If it doesn't please log an issue.
41+
42+
### `perform_all_later`
43+
44+
```ruby
45+
ActiveJob.perform_all_later([HelloJob.new("Jamie"), HelloJob.new("John"), HelloJob.new("Alex")])
46+
```
47+
48+
Under the hood, this uses `Delayed::Job.insert_all` to insert all the jobs into the database using a single SQL query.
49+
50+
### Set `run_at` when bulk enqueueing
51+
52+
```ruby
53+
job = HelloJob.new("Alex")
54+
job.run_at = 1.hour.from_now
55+
ActiveJob.perform_all_later([job])
56+
```
57+
58+
This is the equivalent to `HelloJob.set(wait: 1.hour).perform_later("Alex")`.
59+
60+
### Extra attributes via `job_attributes`
61+
62+
```ruby
63+
job = HelloJob.new("Alex")
64+
job.job_attributes = { metadata: "foo" }
65+
job.enqueue
66+
```
67+
68+
```ruby
69+
job = HelloJob.new("Alex")
70+
job.job_attributes = { metadata: "foo" }
71+
ActiveJob.perform_all_later([job])
72+
```
73+
74+
These examples would write `"foo"` into the `metadata` column on the `delayed_jobs` table. This works with any type of column, not just strings.
75+
3776
## Support
3877

3978
If you want to report a bug, or have ideas, feedback or questions about the gem, [let me know via GitHub issues](https://github.com/TandaHQ/delayed_job-active_job/issues/new) and I will do my best to provide a helpful answer. Happy hacking!

0 commit comments

Comments
 (0)