用于 Django 的 RabbitMQ 异步任务队列。
项目描述
.. 图像:: https://coveralls.io/repos/github/chris104957/django-carrot/badge.svg?branch=master
:target: https://coveralls.io/github/chris104957/django-carrot?branch =master
.. 图片:: https://readthedocs.org/projects/django-carrot/badge/?version=latest
:target: http://django-carrot.readthedocs.io/en/latest/?badge=
。 . 图片:: https://travis-ci.org/chris104957/django-carrot.svg?branch=master
:目标: https://travis-ci.org/chris104957/django-carrot.svg?branch=master
。 . 图片:: https://coveralls.io/repos/github/chris104957/django-carrot/badge.svg?branch=master
:目标: https://coveralls.io/github/chris104957/django-carrot?branch=大师)
.. 图片:: https://badge.fury.io/py/django-carrot.svg
:target: https://badge.fury.io/py/django-carrot
.. 图片:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
:target: https:// /opensource.org/licenses/Apache-2.0
.. image:: /docs/source/images/carrot-logo-big.png
:align: center
**django-carrot** 是 Django 项目的轻量级任务队列后端使用 RabbitMQ 消息代理,
强调快速简便的配置和任务跟踪
安装
------------
安装 django-carrot:
.. code-block:: bash
pip install django-carrot
安装和运行 RabbitMQ
.. code-block:: bash
brew install rabbitmq
brew services start rabbitmq
配置
-------------
1. 将胡萝卜添加到 Django 项目的设置模块:
.. code-block:: python
INSTALLED_APPS = [
...
'carrot',
...
]
2. 应用胡萝卜迁移到项目数据库:
.. code-block:: python
python manage.py migrate carrot
用法
-----
启动服务:
.. code-block:: bash
python manage.py carrot_daemon start
异步运行任务:
.. 代码块:: python
from carrot.utilities import publish_message
def my_task(**kwargs):
return 'hello world'
publish_message(my_task, hello=True)
要安排任务以给定的时间间隔运行
.. code-block:: python
from carrot.utilities import create_scheduled_task
create_scheduled_task(my_task, {'seconds': 5}, hello=True)
.. 注意::
必须执行上述命令来自 Django 环境
Docker
------
一个示例 docker 配置可用`here <https://github.com/chris104957/django-carrot-docker>`_
完整文档
----- ---------
完整的文档可在`这里获得 <https://django-carrot.readthedocs.io/>`_
支持
-------
如果您有任何问题,请 `log一个问题<https://github.com/chris104957/django-carrot/issues/new>`_
贡献
------------
Django-carrot 使用 `Packagr <https://www.packagr.app/>`_ 来共享开发版本。如果您想访问它,
请将您的电子邮件地址发送到 christopherdavies553@gmail.com,以便我可以给您访问
许可
-------
该项目在 Apache 许可下获得许可。
来自 `www.flaticon.com <www.flaticon.com>`_ 的 Trinh Ho 制作的图标由 CC 3.0 BY 许可
:target: https://coveralls.io/github/chris104957/django-carrot?branch =master
.. 图片:: https://readthedocs.org/projects/django-carrot/badge/?version=latest
:target: http://django-carrot.readthedocs.io/en/latest/?badge=
。 . 图片:: https://travis-ci.org/chris104957/django-carrot.svg?branch=master
:目标: https://travis-ci.org/chris104957/django-carrot.svg?branch=master
。 . 图片:: https://coveralls.io/repos/github/chris104957/django-carrot/badge.svg?branch=master
:目标: https://coveralls.io/github/chris104957/django-carrot?branch=大师)
.. 图片:: https://badge.fury.io/py/django-carrot.svg
:target: https://badge.fury.io/py/django-carrot
.. 图片:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
:target: https:// /opensource.org/licenses/Apache-2.0
.. image:: /docs/source/images/carrot-logo-big.png
:align: center
**django-carrot** 是 Django 项目的轻量级任务队列后端使用 RabbitMQ 消息代理,
强调快速简便的配置和任务跟踪
安装
------------
安装 django-carrot:
.. code-block:: bash
pip install django-carrot
安装和运行 RabbitMQ
.. code-block:: bash
brew install rabbitmq
brew services start rabbitmq
配置
-------------
1. 将胡萝卜添加到 Django 项目的设置模块:
.. code-block:: python
INSTALLED_APPS = [
...
'carrot',
...
]
2. 应用胡萝卜迁移到项目数据库:
.. code-block:: python
python manage.py migrate carrot
用法
-----
启动服务:
.. code-block:: bash
python manage.py carrot_daemon start
异步运行任务:
.. 代码块:: python
from carrot.utilities import publish_message
def my_task(**kwargs):
return 'hello world'
publish_message(my_task, hello=True)
要安排任务以给定的时间间隔运行
.. code-block:: python
from carrot.utilities import create_scheduled_task
create_scheduled_task(my_task, {'seconds': 5}, hello=True)
.. 注意::
必须执行上述命令来自 Django 环境
Docker
------
一个示例 docker 配置可用`here <https://github.com/chris104957/django-carrot-docker>`_
完整文档
----- ---------
完整的文档可在`这里获得 <https://django-carrot.readthedocs.io/>`_
支持
-------
如果您有任何问题,请 `log一个问题<https://github.com/chris104957/django-carrot/issues/new>`_
贡献
------------
Django-carrot 使用 `Packagr <https://www.packagr.app/>`_ 来共享开发版本。如果您想访问它,
请将您的电子邮件地址发送到 christopherdavies553@gmail.com,以便我可以给您访问
许可
-------
该项目在 Apache 许可下获得许可。
来自 `www.flaticon.com <www.flaticon.com>`_ 的 Trinh Ho 制作的图标由 CC 3.0 BY 许可