refactor(cron): migrate cron jobs to foundation scheduler

Replace custom goroutine-based scheduling in cron jobs with centralized
foundation scheduler. Each cron job now exposes a RunOnce method called
by the scheduler instead of managing its own ticker loop.

Changes:
- Remove interval/enabled config from cron job structs
- Convert Start() methods to RunOnce() for all cron jobs
- Add scheduler setup in main.go with configurable intervals
- Update foundation dependency to v0.6.0 for scheduler support
- Update tests to validate RunOnce nil-safety
This commit is contained in:
zenfun
2025-12-31 20:42:25 +08:00
parent 4bcd2b4167
commit 05caed37c2
9 changed files with 62 additions and 139 deletions

3
go.mod
View File

@@ -4,7 +4,7 @@ go 1.24.5
require (
github.com/alicebob/miniredis/v2 v2.35.0
github.com/ez-api/foundation v0.5.0
github.com/ez-api/foundation v0.6.0
github.com/gin-gonic/gin v1.11.0
github.com/pelletier/go-toml/v2 v2.2.4
github.com/redis/go-redis/v9 v9.17.2
@@ -60,6 +60,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.54.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rs/zerolog v1.34.0 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect