// catchup.go — server-side catch-up for intermittent (non-always-on) // hosts. When such a host reconnects we wait a short settle window, // then dispatch a backup for any schedule whose window elapsed while // the host was asleep. This is separate from pending_runs: a host that // was asleep never fired its local cron, so no pending row exists. package http import ( "time" ) // scheduleOverdue reports whether a schedule's most recent expected // fire is newer than the host's last successful backup — i.e. a window // passed with no backup. A nil lastBackup means "never backed up" and // is always overdue (provided the cron parses). An unparseable cron is // treated as not-overdue so a bad expression can never trigger a // surprise dispatch. Uses the same cronParser the agent's scheduler // and schedule validation use, so interpretation is identical. func scheduleOverdue(cronExpr string, lastBackup *time.Time, now time.Time) bool { sched, err := cronParser.Parse(cronExpr) if err != nil { return false } if lastBackup == nil { return true } next := sched.Next(*lastBackup) return !next.After(now) }