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
@@ -90,3 +90,30 @@ func (w *MonitoringLeaseRecoveryWorker) runOnce(parent context.Context) {
w.logger.Info("monitoring lease recovery completed", zap.Int64("expired_task_count", expiredCount))
}
}
func (w *MonitoringLeaseRecoveryWorker) 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)
expiredCount, err := tenantapp.ExpireMonitoringLeasedTasks(ctx, tx, nil, time.Now().UTC())
if err != nil {
return map[string]any{"stage": "expire"}, err
}
if err := tx.Commit(ctx); err != nil {
return map[string]any{"stage": "commit"}, err
}
return map[string]any{
"expired_task_count": expiredCount,
"duration_ms": time.Since(startedAt).Milliseconds(),
}, nil
}