Skip to main content

Crate celers_beat

Crate celers_beat 

Source
Expand description

Periodic task scheduler (Celery Beat equivalent)

This crate provides scheduled task execution with various schedule types and persistent state management.

§Schedule Types

  • Interval: Execute every N seconds
  • Crontab: Execute based on cron expression (requires cron feature)
  • Solar: Execute at solar events (sunrise, sunset) (requires solar feature)
  • OneTime: Execute once at a specific timestamp (auto-cleanup after execution)

§Persistence

The scheduler supports automatic state persistence to JSON files, preserving schedules and execution history across restarts:

use celers_beat::{BeatScheduler, Schedule, ScheduledTask};

// Load scheduler from file (or create new if file doesn't exist)
let mut scheduler = BeatScheduler::load_from_file("schedules.json").unwrap();

// Add tasks - automatically saved to file
let task = ScheduledTask::new("send_report".to_string(), Schedule::interval(60));
scheduler.add_task(task).unwrap();

// State persists across restarts

§Basic Example

use celers_beat::{Schedule, ScheduledTask};

let schedule = Schedule::interval(60);  // Every 60 seconds
let task = ScheduledTask::new("send_report".to_string(), schedule);

Re-exports§

pub use heartbeat::BeatHeartbeat;
pub use heartbeat::BeatRole;
pub use heartbeat::HeartbeatConfig;
pub use heartbeat::HeartbeatInfo;
pub use heartbeat::HeartbeatStats;
pub use alert::*;
pub use config::*;
pub use history::*;
pub use lock::*;
pub use schedule::*;
pub use schedule_ext::*;
pub use scheduler::*;
pub use scheduler_ext::*;
pub use task::*;
pub use wfq::*;

Modules§

alert
Alert management and monitoring
config
Schedule error types and configuration
heartbeat
Beat scheduler heartbeat and failover
history
Execution history and health tracking
lock
Lock management for schedule execution
schedule
Schedule types and calendar support
schedule_ext
Extended schedule types
scheduler
Beat scheduler and related types
scheduler_ext
Extended BeatScheduler functionality
task
Scheduled task types
wfq
Weighted Fair Queuing (WFQ) types

Type Aliases§

FailureCallback
Failure notification callback type