Skip to content

Commit

Permalink
Fix documentation for enqueue_after_transaction_commit
Browse files Browse the repository at this point in the history
Correct some grammar and update the framework defaults documentation
from use `true` and `false` to `:never` and `:default`.
  • Loading branch information
p8 committed Apr 4, 2024
1 parent d4c40b6 commit 97e2e93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
14 changes: 9 additions & 5 deletions guides/source/configuring.md
Expand Up @@ -2768,9 +2768,13 @@ end
Controls whether Active Job's `#perform_later` and similar methods automatically defer
the job queuing to after the current Active Record transaction is committed.

It can be set to `:never` to never defer the enqueue, to `:always` always defer
the enqueue, or to `:default` to let the queue adapter define if it should be defered
or not. Active Job backends that use the same database than Active Record as a queue,
It can be set to:

* `:never` - Never defer the enqueue.
* `:always` - Always defer the enqueue.
* `:default` - Let the queue adapter define the behaviour.

Active Job backends that use the same database as Active Record as a queue,
should generally prevent the deferring, and others should allow it.

Example:
Expand All @@ -2783,8 +2787,8 @@ end
```

In this example, if the configuration is set to `:never`, the job will
be enqueued immediately, even thought the `Topic` hasn't been committed yet.
Because of this, if the job is picked up almost emmediately, or if the
be enqueued immediately, even though the `Topic` hasn't been committed yet.
Because of this, if the job is picked up almost immediately, or if the
transaction doesn't succeed for some reason, the job will fail to find this
topic in the database.

Expand Down
Expand Up @@ -19,12 +19,14 @@
# NewTopicNotificationJob.perform_later(topic)
# end
#
# In this example, if `enqueue_after_transaction_commit` is `false` the job will
# be enqueued immediately, even thought the `Topic` hasn't been committed yet.
# Because of this, if the job is picked up almost emmediately, it will fail to
# find this topic in the databse.
# With `enqueue_after_transaction_commit = true`, the job will be actually enqueued
# after the transaction has been committed.
# In this example, if the configuration is set to `:never`, the job will
# be enqueued immediately, even though the `Topic` hasn't been committed yet.
# Because of this, if the job is picked up almost immediately, or if the
# transaction doesn't succeed for some reason, the job will fail to find this
# topic in the database.
#
# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter
# will define the behaviour.
#
# Note: Active Job backends can disable this feature. This is generally used by
# backends that use the same database than Active Record as a queue, hence they
Expand Down

0 comments on commit 97e2e93

Please sign in to comment.