Metadata-Version: 2.4
Name: celerybeat-mongo2
Version: 0.2.2
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-mongo2
#################

|pypi|

A maintained fork of `zmap/celerybeat-mongo <https://github.com/zmap/celerybeat-mongo>`_,
which has been archived upstream.

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-mongo2 Python egg::

    # pip install celerybeat-mongo2

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

    $ celery -A myproj 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 schedules.
* 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 supports Interval, Crontab and Solar schedules.
Schedules easily can be manipulated using the mongoengine models in celerybeatmongo.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="*", month_of_year="*")
    periodic.save()


Example creating solar periodic task
---------------------------------------------

A solar schedule fires at a solar event (sunrise, sunset, etc.) at a given
latitude/longitude. For example, to send a morning briefing at sunrise in London::

    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="Morning briefing", task="proj.send_briefing")
    periodic.schedule = PeriodicTask.Solar(
        event="sunrise",
        latitude=51.5074,
        longitude=-0.1278,
    )
    periodic.save()

Supported events: dawn_astronomical, dawn_nautical, dawn_civil, sunrise, solar_noon, sunset, dusk_civil, dusk_nautical, dusk_astronomical.

.. |pypi| image:: https://img.shields.io/pypi/v/celerybeat-mongo2.svg
    :alt: PyPI version
    :target: https://pypi.org/project/celerybeat-mongo2/
