Module celery::beat

source ·
Expand description

Celery Beat is an app that can automatically produce tasks at scheduled times.

Terminology

This is the terminology used in this module (with references to the corresponding names in the Python implementation):

  • schedule: the strategy used to decide when a task must be executed (each scheduled task has its own schedule);
  • scheduled task: a task together with its schedule (it more or less corresponds to a schedule entry in Python);
  • scheduler: the component in charge of keeping track of tasks to execute;
  • scheduler backend: the component that updates the internal state of the scheduler according to to an external source of truth (e.g., a database); there is no equivalent in Python, due to the fact that another pattern is used (see below);
  • beat: the service that drives the execution, calling the appropriate methods of the scheduler in an infinite loop (called just service in Python).

The main difference with the architecture used in Python is that in Python there is a base scheduler class which contains the scheduling logic, then different implementations use different strategies to synchronize the scheduler. Here instead we have only one scheduler struct, and the different backends correspond to the different scheduler implementations in Python.

Structs

A Beat app is used to send out scheduled tasks. This is the struct that is created with the beat! macro.
Used to create a Beat app with a custom configuration.
A schedule that can be used to execute tasks using Celery’s crontab syntax.
A schedule that can be used to execute tasks at regular intervals.
A task which is scheduled for execution. It contains the task to execute, the queue where to send it and the schedule which determines when to do it.
A Scheduler is in charge of executing scheduled tasks when they are due.

Traits

The trait that all schedules implement.
A SchedulerBackend is in charge of keeping track of the internal state of the scheduler according to some source of truth, such as a database.