Metadata-Version: 2.4
Name: celerybeat-mongo2
Version: 0.2.1
Summary: A Celery Beat Scheduler that uses MongoDB to store both schedule definitions and status information
Home-page: https://github.com/diaxoaine/celerybeat-mongo
Author: Zakir Durumeric
Author-email: zakird@gmail.com
Maintainer: Zakir Durumeric
Maintainer-email: zakird@gmail.com
License: Apache License, Version 2.0
Keywords: python celery beat periodic task mongodb
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Communications
Classifier: Topic :: System :: Distributed Computing
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Operating System :: OS Independent
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: setuptools
Requires-Dist: pymongo==4.17.0
Requires-Dist: mongoengine==0.29.3
Requires-Dist: celery==5.6.3
Requires-Dist: blinker
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: maintainer
Dynamic: maintainer-email
Dynamic: requires-dist
Dynamic: summary

celerybeat-mongo
################

This is a `Celery Beat Scheduler <http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html/>`_
that stores both the schedules themselves and their status
information in a backend Mongo database. It can be installed by
installing the celerybeat-mongo Python egg::

    # pip install celerybeat-mongo2

And specifying the scheduler when running Celery Beat, e.g.::

    $ celery beat -S celerybeatmongo.schedulers.MongoScheduler

Settings
########

The settings for the scheduler are defined in your celery configuration file
similar to how other aspects of Celery are configured:

* mongodb_scheduler_url: The mongodb `url <https://docs.mongodb.com/manual/reference/connection-string/>`_ connection used to store task results.
* mongodb_scheduler_db: The Mongodb database name
* mongodb_scheduler_collection (optional): the collection name used by model. If no value are specified, the default value will be used: **schedules**.

Usage
===================
Celerybeat-mongo just supports Interval and Crontab schedules.
Schedules easily can be manipulated using the mongoengine models in celerybeat mongo.models module.

Example creating interval-based periodic task
---------------------------------------------

To create a periodic task executing at an interval you must first
create the interval object::

    from celery import Celery
    from celerybeatmongo import PeriodicTask, connect_from_app

    app = Celery("hello")
    app.conf.update(
        mongodb_scheduler_db="my_project",
        mongodb_scheduler_url="mongodb://localhost:27017",
    )
    connect_from_app(app)

    periodic = PeriodicTask(
        name='Importing contacts',
        task="proj.import_contacts",
        schedule=PeriodicTask.Interval(every=10, period="seconds"),
    )
    periodic.save()


Example creating crontab periodic task
---------------------------------------------

A crontab schedule has the fields: minute, hour, day_of_week, day_of_month and month_of_year, so if you want the equivalent of a 30 7 * * 1 (Executes every Monday morning at 7:30 a.m) crontab entry you specify::


    from celery import Celery
    from celerybeatmongo import PeriodicTask, connect_from_app

    app = Celery("hello")
    app.conf.update(
        mongodb_scheduler_db="my_project",
        mongodb_scheduler_url="mongodb://localhost:27017",
    )
    connect_from_app(app)

    periodic = PeriodicTask(name="Send Email Notification", task="proj.notify_customers")
    periodic.schedule = PeriodicTask.Crontab(minute="30", hour="7", day_of_week="1",
                               day_of_month="0", month_of_year="*")
    periodic.save()
