Skip to content

Scheduling

Register and run scheduled jobs through module lifecycle hooks.

nestforge = { version = "1", features = ["schedule"] }

Scheduling support is built around:

  • ScheduleRegistry
  • ScheduleRegistryBuilder
  • start_schedules
  • shutdown_schedules

The standard approach is to register a ScheduleRegistry provider and start it during application bootstrap:

#[module(
providers = [build_schedule_registry()?],
on_application_bootstrap = [nestforge::start_schedules],
on_application_shutdown = [nestforge::shutdown_schedules]
)]
pub struct AppModule;

The current registry supports:

  • repeated jobs with every(...)
  • one-shot delayed jobs with after(...)
  • named variants with every_named(...) and after_named(...)

Scheduling belongs in modules when the jobs are part of application behavior, not as hidden global threads. This keeps lifecycle and shutdown behavior explicit.