feat(archied): run daemon maintenance as built-in schedules

This commit is contained in:
sam committed 2026-10-26 00:51:53 +11:00
1 parent cc5789eb5f
commit 87ac7b693c
3 files changed
+36 -13

No files matched your search

+8 -7
View File
@@ -448,6 +448,12 @@ func (d *Daemon) pollIssuesWithConfig(ctx context.Context, fg forge.Forge, cfg c
func (d *Daemon) RunOnce(ctx context.Context) {
defer d.WaitForTasks()
d.watchCallWaits(ctx)
// One pass has no scheduler, so it runs the maintenance jobs itself.
for _, job := range d.BuiltinJobs() {
if err := job.Run(ctx); err != nil {
d.Log.WarnContext(ctx, "built-in job failed", "job", job.ID, "err", err)
}
}
d.Cycle(ctx)
if d.Tasks == nil {
return
@@ -465,15 +471,10 @@ func (d *Daemon) RunOnce(ctx context.Context) {
}
}
// Cycle is one poll pass: run every built-in job, then turn captured events
// and review reactions into tasks. Draining queued tasks is the caller's job
// Cycle is one poll pass: turn captured events and review reactions into
// tasks; maintenance runs as built-in schedules. Draining queued tasks is the caller's job
// (drainLoop in Run, drainNATS in RunOnce) so there is one drainer.
func (d *Daemon) Cycle(ctx context.Context) {
for _, job := range d.BuiltinJobs() {
if err := job.Run(ctx); err != nil {
d.Log.WarnContext(ctx, "built-in job failed", "job", job.ID, "err", err)
}
}
d.dispatchBindings(ctx)
d.drainReactions(ctx)
}