Skip to main content

Crate a3s_cron

Crate a3s_cron 

Source
Expand description

A3S Cron - Task scheduling library

Provides cron-based task scheduling with:

  • Standard 5-field cron syntax parsing
  • Natural language schedule parsing (English & Chinese)
  • Task persistence and monitoring
  • CRUD operations for job management

§Quick Start

use a3s_cron::{CronManager, CronJob, JobStatus, parse_natural};

// Create a manager with file-based storage
let manager = CronManager::new("/path/to/workspace").await?;

// Add a job using natural language
let schedule = parse_natural("every day at 2am")?;  // Returns "0 2 * * *"
let job = manager.add_job("backup", &schedule, "backup.sh").await?;

// Or use Chinese
let schedule = parse_natural("每天凌晨2点")?;  // Returns "0 2 * * *"

// List all jobs
let jobs = manager.list_jobs().await?;

// Start the scheduler
manager.start().await?;

Re-exports§

pub use natural::parse_natural;

Modules§

natural
Natural language parser for cron expressions
telemetry
OpenTelemetry telemetry for the A3S Cron scheduler.

Structs§

AgentJobConfig
Agent configuration for agent-mode cron jobs
CronExpression
A parsed cron expression
CronJob
A cron job definition
CronManager
Cron manager for job scheduling and execution
FileCronStore
File-based cron store
JobExecution
A job execution record
MemoryCronStore
In-memory cron store for testing

Enums§

CronError
Cron library errors
ExecutionStatus
Execution result status
JobStatus
Job status
JobType
Job type — determines how the command is executed
SchedulerEvent
Scheduler events for monitoring

Traits§

AgentExecutor
Trait for executing agent-mode cron jobs.
CronStore
Cron storage trait

Type Aliases§

Result
Result type alias for cron operations