Epic: PingSpider MVP - Distributed Uptime & Latency Monitor
Sprint: 1
Story Points: 8
Description
Create a background task scheduler that periodically checks all registered endpoints and stores metrics in SurrealDB.
Acceptance Criteria
Technical Notes
- Use
tokio::time::interval for periodic execution
- Use
tokio::select! for shutdown handling
- Limit concurrent checks to prevent resource exhaustion (e.g., max 100 concurrent)
- Use
Arc<RwLock<HashMap>> or similar for in-memory endpoint tracking
- Consider using
tokio-cron-scheduler for more complex scheduling
Scheduler Logic Flow
- On startup: Load all endpoints from DB
- For each endpoint: Spawn a task with its check_interval
- On interval tick: Execute health check
- Store result in metrics table
- Update endpoint status if changed
- On shutdown: Cancel all tasks gracefully
Dependencies
tokio with signal feature for graceful shutdown
- Optional:
tokio-cron-scheduler crate
Files to Create/Modify
src/monitoring/scheduler.rs
src/sys/init.rs (start scheduler on app init)
src/rts/scheduler.rs (status endpoint handler)
Definition of Done
- Scheduler runs all endpoint checks on schedule
- Metrics correctly stored in SurrealDB
- No memory leaks or resource exhaustion
- Graceful shutdown works
- Load testing completed (100+ endpoints)
- Code reviewed and merged to main
Epic: PingSpider MVP - Distributed Uptime & Latency Monitor
Sprint: 1
Story Points: 8
Description
Create a background task scheduler that periodically checks all registered endpoints and stores metrics in SurrealDB.
Acceptance Criteria
src/monitoring/scheduler.rswith async task schedulercheck_intervaltokio::spawnfor parallelization)metricstableGET /api/scheduler/statusTechnical Notes
tokio::time::intervalfor periodic executiontokio::select!for shutdown handlingArc<RwLock<HashMap>>or similar for in-memory endpoint trackingtokio-cron-schedulerfor more complex schedulingScheduler Logic Flow
Dependencies
tokiowithsignalfeature for graceful shutdowntokio-cron-schedulercrateFiles to Create/Modify
src/monitoring/scheduler.rssrc/sys/init.rs(start scheduler on app init)src/rts/scheduler.rs(status endpoint handler)Definition of Done