1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Cron job scheduling for Armature framework.
//!
//! Provides a robust cron job scheduler with support for:
//! - ⏰ Standard cron expressions
//! - 📛 Named jobs with metadata
//! - 🚀 Async job execution
//! - 🪝 Job lifecycle hooks
//! - ❌ Error handling and retry logic
//! - 🔒 Job overlap prevention
//!
//! ## Quick Start - Cron Expressions
//!
//! ```
//! use armature_cron::CronExpression;
//!
//! // Parse a cron expression for "every hour"
//! let expr = CronExpression::parse("0 0 * * * *").unwrap();
//!
//! // Get next execution time
//! let now = chrono::Utc::now();
//! let next = expr.next_after(now);
//!
//! assert!(next.is_some());
//! assert!(next.unwrap() > now);
//! ```
//!
//! ## Cron Expression Presets
//!
//! ```
//! use armature_cron::expression::{CronExpression, CronPresets};
//!
//! // Use preset expressions
//! let every_minute = CronExpression::parse(CronPresets::EVERY_MINUTE).unwrap();
//! let every_hour = CronExpression::parse(CronPresets::EVERY_HOUR).unwrap();
//! let daily = CronExpression::parse(CronPresets::DAILY).unwrap();
//!
//! // Verify they parse correctly
//! let now = chrono::Utc::now();
//! assert!(every_minute.next_after(now).unwrap() > now);
//! assert!(every_hour.next_after(now).unwrap() > now);
//! assert!(daily.next_after(now).unwrap() > now);
//! ```
//!
//! ## Complete Example
//!
//! ```no_run
//! use armature_cron::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), CronError> {
//! let mut scheduler = CronScheduler::new();
//!
//! // Schedule a job to run every minute
//! scheduler.add_job(
//! "cleanup",
//! "0 * * * * *",
//! |context| Box::pin(async move {
//! println!("Running cleanup job");
//! Ok(())
//! })
//! )?;
//!
//! // Start the scheduler
//! scheduler.start().await?;
//!
//! Ok(())
//! }
//! ```
pub use ;
pub use CronExpression;
pub use ;
pub use ;
/// Re-export commonly used types