Skip to content

Commit

Permalink
Add keywords to ActiveJob Concurrency and add testing example
Browse files Browse the repository at this point in the history
Connecys to #317.
  • Loading branch information
bensheldon authored Aug 2, 2021
1 parent d365e3e commit 1808433
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ GoodJob includes a Dashboard as a mountable `Rails::Engine`.
### ActiveJob concurrency
GoodJob can extend ActiveJob to provide limits on concurrently running jobs, either at time of _enqueue_ or at _perform_.
GoodJob can extend ActiveJob to provide limits on concurrently running jobs, either at time of _enqueue_ or at _perform_. Limiting concurrency can help prevent duplicate, double or unecessary jobs from being enqueued, or race conditions when performing, for example when interacting with 3rd-party APIs.
**Note:** Limiting concurrency at _enqueue_ requires Rails 6.0+ because Rails 5.2 does not support `throw :abort` in ActiveJob callbacks.
Expand All @@ -361,6 +361,13 @@ class MyJob < ApplicationJob
end
```
When testing, the resulting concurrency key value can be inspected:
```ruby
job = MyJob.perform_later("Alice")
job.good_job_concurrency_key #=> "Unique-Alice"
```
### Cron-style repeating/recurring jobs
GoodJob can enqueue jobs on a recurring basis that can be used as a replacement for cron.
Expand Down

0 comments on commit 1808433

Please sign in to comment.