Configuration
Configure the Cron module inconfig.yaml:
config.yaml
Available Adapters
- KvCronAdapter (Default)
- Redis
File-based or in-memory storage:
Creating Scheduled Functions
Define cron triggers with standard cron expressions:index.ts
Cron Expression Format
Cron expressions use the standard 5-field format:Common Cron Patterns
Input Format
Cron-triggered functions receive timing information:Conditional Execution
Use conditions to control whether a scheduled task should run:Example Use Cases
Daily Database Cleanup
Hourly Data Sync
Weekly Reports
Periodic Health Checks
Timezone Considerations
Example for timezone-aware scheduling:Best Practices
- Idempotent Functions: Make sure cron functions can safely run multiple times
- Error Handling: Always handle errors gracefully
- Monitoring: Log execution times and results
- Avoid Overlaps: Ensure tasks complete before next scheduled run
- Use Conditions: Filter execution based on business rules
Debugging Cron Jobs
View registered cron jobs in logs:Source Code Reference
- Module:
src/modules/cron/cron.rs:29 - Trigger registration:
src/modules/cron/cron.rs:88 - Adapters:
src/modules/cron/adapters/