feat: add ops scheduler control center

This commit is contained in:
2026-05-20 10:46:49 +08:00
parent 98f73c5bea
commit e82ae56236
19 changed files with 2766 additions and 20 deletions
@@ -116,3 +116,32 @@ func (w *MonitoringReceivedInspectionWorker) runOnce(parent context.Context) {
)
}
}
func (w *MonitoringReceivedInspectionWorker) RunOnce(parent context.Context) (map[string]any, error) {
if w == nil || w.monitoringPool == nil {
return map[string]any{"skipped": true, "reason": "worker_not_ready"}, nil
}
startedAt := time.Now()
ctx, cancel := context.WithTimeout(parent, w.timeout)
defer cancel()
tx, err := w.monitoringPool.Begin(ctx)
if err != nil {
return map[string]any{"stage": "begin"}, err
}
defer tx.Rollback(ctx)
now := time.Now().UTC()
items, err := tenantapp.MarkMonitoringStaleReceivedTasks(ctx, tx, now, w.threshold, w.limit)
if err != nil {
return map[string]any{"stage": "inspect"}, err
}
if err := tx.Commit(ctx); err != nil {
return map[string]any{"stage": "commit"}, err
}
return map[string]any{
"overdue_task_count": len(items),
"threshold_seconds": int64(w.threshold.Seconds()),
"duration_ms": time.Since(startedAt).Milliseconds(),
}, nil
}