-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-39849: revise job batching docs #2994
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,24 +9,27 @@ Queues | |
:values: tutorial | ||
|
||
.. meta:: | ||
:keywords: php framework, odm, code example | ||
:keywords: php framework, odm, code example, jobs | ||
|
||
If you want to use MongoDB as your database backend for Laravel Queue, change | ||
the driver in ``config/queue.php``: | ||
To use MongoDB as your database for Laravel Queue, change | ||
the driver in your application's ``config/queue.php`` file: | ||
|
||
.. code-block:: php | ||
|
||
'connections' => [ | ||
'database' => [ | ||
'driver' => 'mongodb', | ||
// You can also specify your jobs specific database created on config/database.php | ||
// You can also specify your jobs-specific database created on config/database.php | ||
'connection' => 'mongodb', | ||
'collection' => 'jobs', | ||
'queue' => 'default', | ||
'retry_after' => 60, | ||
], | ||
], | ||
|
||
The following table describes properties that you can specify to configure | ||
the behavior of the queue: | ||
|
||
.. list-table:: | ||
:header-rows: 1 | ||
:widths: 25 75 | ||
|
@@ -35,22 +38,29 @@ the driver in ``config/queue.php``: | |
- Description | ||
|
||
* - ``driver`` | ||
- **Required**. Specifies the queue driver to use. Must be ``mongodb``. | ||
- **Required**. Specifies the queue driver to use. The value of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find it cumbersome to repeat "Specifies" for every setting. |
||
this property must be ``mongodb``. | ||
|
||
* - ``connection`` | ||
- The database connection used to store jobs. It must be a ``mongodb`` connection. The driver uses the default connection if a connection is not specified. | ||
- Specifies the database connection used to store jobs. It must be a | ||
``mongodb`` connection. The driver uses the default connection if | ||
a connection is not specified. | ||
|
||
* - ``collection`` | ||
- **Required**. Name of the MongoDB collection to store jobs to process. | ||
- **Required**. Specifies the name of the MongoDB collection to | ||
store jobs to process. | ||
|
||
* - ``queue`` | ||
- **Required**. Name of the queue. | ||
- **Required**. Specifies the name of the queue. | ||
|
||
* - ``retry_after`` | ||
- Specifies how many seconds the queue connection should wait before retrying a job that is being processed. Defaults to ``60``. | ||
- Specifies how many seconds the queue connection should wait | ||
before retrying a job that is being processed. The value is | ||
``60`` by default. | ||
|
||
If you want to use MongoDB to handle failed jobs, change the database in | ||
``config/queue.php``: | ||
To use MongoDB to handle failed jobs, create a ``failed`` entry in your | ||
application's ``config/queue.php`` file and specify the database and | ||
collection: | ||
|
||
.. code-block:: php | ||
|
||
|
@@ -60,6 +70,9 @@ If you want to use MongoDB to handle failed jobs, change the database in | |
'collection' => 'failed_jobs', | ||
], | ||
|
||
The following table describes properties that you can specify to configure | ||
how to handle failed jobs: | ||
|
||
.. list-table:: | ||
:header-rows: 1 | ||
:widths: 25 75 | ||
|
@@ -68,32 +81,41 @@ If you want to use MongoDB to handle failed jobs, change the database in | |
- Description | ||
|
||
* - ``driver`` | ||
- **Required**. Specifies the queue driver to use. Must be ``mongodb``. | ||
- **Required**. Specifies the queue driver to use. The value of | ||
this property must be ``mongodb``. | ||
|
||
* - ``connection`` | ||
- The database connection used to store jobs. It must be a ``mongodb`` connection. The driver uses the default connection if a connection is not specified. | ||
- Specifies the database connection used to store jobs. It must be | ||
a ``mongodb`` connection. The driver uses the default connection | ||
if a connection is not specified. | ||
|
||
* - ``collection`` | ||
- Name of the MongoDB collection to store failed jobs. Defaults to ``failed_jobs``. | ||
|
||
- Specifies the name of the MongoDB collection to store failed | ||
jobs. The value is ``failed_jobs`` by default. | ||
|
||
Add the service provider in ``config/app.php``: | ||
Then, add the service provider in your application's | ||
``config/app.php`` file: | ||
|
||
.. code-block:: php | ||
|
||
MongoDB\Laravel\MongoDBQueueServiceProvider::class, | ||
|
||
|
||
Job Batching | ||
------------ | ||
|
||
`Job batching <https://laravel.com/docs/{+laravel-docs-version+}/queues#job-batching>`__ | ||
is a Laravel feature to execute a batch of jobs and subsequent actions before, | ||
after, and during the execution of the jobs from the queue. | ||
**Job batching** is a Laravel feature that enables you to execute a | ||
batch of jobs and subsequent actions before, after, and during the | ||
execution of the jobs from the queue. To learn more about this feature, | ||
rustagir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
see `Job Batching <https://laravel.com/docs/{+laravel-docs-version+}/queues#job-batching>`__ | ||
in the Laravel documentation. | ||
|
||
In MongoDB, you don't have to create a designated collection before | ||
using job batching. The ``job_batches`` collection is created | ||
automatically to store meta-information about your job batches, such as | ||
rustagir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
their completion percentage. | ||
|
||
With MongoDB, you don't have to create any collection before using job batching. | ||
The ``job_batches`` collection is created automatically to store meta | ||
information about your job batches, such as their completion percentage. | ||
To enable job batching, create the ``batching`` entry in your | ||
application's ``config/queue.php`` file: | ||
|
||
.. code-block:: php | ||
|
||
|
@@ -103,6 +125,9 @@ information about your job batches, such as their completion percentage. | |
'collection' => 'job_batches', | ||
], | ||
|
||
The following table describes properties that you can specify to configure | ||
job batching: | ||
|
||
.. list-table:: | ||
:header-rows: 1 | ||
:widths: 25 75 | ||
|
@@ -111,15 +136,19 @@ information about your job batches, such as their completion percentage. | |
- Description | ||
|
||
* - ``driver`` | ||
- **Required**. Specifies the queue driver to use. Must be ``mongodb``. | ||
- **Required**. Specifies the queue driver to use. The value of | ||
this property must be ``mongodb``. | ||
|
||
* - ``connection`` | ||
- The database connection used to store jobs. It must be a ``mongodb`` connection. The driver uses the default connection if a connection is not specified. | ||
- Specifies the database connection used to store jobs. It must be a | ||
``mongodb`` connection. The driver uses the default connection if | ||
a connection is not specified. | ||
|
||
* - ``collection`` | ||
- Name of the MongoDB collection to store job batches. Defaults to ``job_batches``. | ||
- Specifies the name of the MongoDB collection to store job | ||
batches. The value is ``job_batches`` by default. | ||
|
||
Add the service provider in ``config/app.php``: | ||
The, add the service provider in ``config/app.php``: | ||
rustagir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. code-block:: php | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2985 (comment) we decided with @jmikola to comment optional settings.