Schedule Internals
The schedule system stores tasks, tracks when they should run, and executes them with middleware and error handling.
Schedule system components
Specifically, these components are:
ScheduleManager: The entry point for the schedule system, orchestrating the repository, executor, scheduler, and lifecycle events.ScheduleRepository: Stores all the currently registered schedules.ScheduleExecutionScheduler: Determines when a schedule should run next and creates the job adapter.ScheduleJobAdapter: Wraps the underlying job instance (e.g. a cronerCronobject, or a timeout).ScheduleExecutor: Executes schedules, checking their middleware list and handling errors.ScheduleMiddlewareList: Manages middlewares for schedule execution, including filters.ScheduleErrorHandler: Handles middleware and schedule execution errors.
Execution flow
Registration and lifecycle
When you add a schedule, the ScheduleManager stores it in the ScheduleRepository, asks the ScheduleExecutionScheduler to create a job, and then emits ScheduleEventEnum.ScheduleAdd. Removing a schedule follows the same coordination path in reverse and emits ScheduleEventEnum.ScheduleRemove.
Runtime execution
When the job fires, the ScheduleJobAdapter hands control to the ScheduleExecutor, which checks middlewares, executes the schedule's tick() method, and forwards errors to the configured ScheduleErrorHandler.
Next, see the documentation of each component, where you'll find what it does and how to replace it.
Last updated on
