Skip to content

Commit

Permalink
[Fix celery#6074]: Add missing documentation for MongoDB as result ba…
Browse files Browse the repository at this point in the history
…ckend.
  • Loading branch information
rafaelreuber authored and auvipy committed May 8, 2020
1 parent 411413f commit ab8b9a2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/getting-started/first-steps-with-celery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ Keeping Results
If you want to keep track of the tasks' states, Celery needs to store or send
the states somewhere. There are several
built-in result backends to choose from: `SQLAlchemy`_/`Django`_ ORM,
`Memcached`_, `Redis`_, :ref:`RPC <conf-rpc-result-backend>` (`RabbitMQ`_/AMQP),
`MongoDB`_, `Memcached`_, `Redis`_, :ref:`RPC <conf-rpc-result-backend>` (`RabbitMQ`_/AMQP),
and -- or you can define your own.

.. _`Memcached`: http://memcached.org
Expand Down Expand Up @@ -286,9 +286,9 @@ original traceback:
.. warning::

Backends use resources to store and transmit results. To ensure
that resources are released, you must eventually call
:meth:`[email protected]` or :meth:`[email protected]` on
Backends use resources to store and transmit results. To ensure
that resources are released, you must eventually call
:meth:`[email protected]` or :meth:`[email protected]` on
EVERY :class:`~@AsyncResult` instance returned after calling
a task.

Expand Down
55 changes: 55 additions & 0 deletions docs/userguide/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@ Can be one of the following:
Use `Memcached`_ to store the results.
See :ref:`conf-cache-result-backend`.

* mongodb
Use `MongoDB`_ to store the results.
See :ref:`conf-mongodb-result-backend`.

* ``cassandra``
Use `Cassandra`_ to store the results.
See :ref:`conf-cassandra-result-backend`.
Expand Down Expand Up @@ -659,6 +663,7 @@ Can be one of the following:
.. _`SQLAlchemy`: http://sqlalchemy.org
.. _`Memcached`: http://memcached.org
.. _`MongoDB`: http://mongodb.org
.. _`Redis`: https://redis.io
.. _`Cassandra`: http://cassandra.apache.org/
.. _`Elasticsearch`: https://aws.amazon.com/elasticsearch-service/
Expand Down Expand Up @@ -974,6 +979,56 @@ setting:
This setting is no longer used as it's now possible to specify
the cache backend directly in the :setting:`result_backend` setting.

.. _conf-mongodb-result-backend:

MongoDB backend settings
------------------------

.. note::

The MongoDB backend requires the :mod:`pymongo` library:
http://github.com/mongodb/mongo-python-driver/tree/master

.. setting:: mongodb_backend_settings

mongodb_backend_settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is a dict supporting the following keys:

* database
The database name to connect to. Defaults to ``celery``.

* taskmeta_collection
The collection name to store task meta data.
Defaults to ``celery_taskmeta``.

* max_pool_size
Passed as max_pool_size to PyMongo's Connection or MongoClient
constructor. It is the maximum number of TCP connections to keep
open to MongoDB at a given time. If there are more open connections
than max_pool_size, sockets will be closed when they are released.
Defaults to 10.

* options

Additional keyword arguments to pass to the mongodb connection
constructor. See the :mod:`pymongo` docs to see a list of arguments
supported.

.. _example-mongodb-result-config:

Example configuration
~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python
result_backend = 'mongodb://localhost:27017/'
mongodb_backend_settings = {
'database': 'mydb',
'taskmeta_collection': 'my_taskmeta_collection',
}
.. _conf-redis-result-backend:

Redis backend settings
Expand Down

0 comments on commit ab8b9a2

Please sign in to comment.