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
@@ -92,6 +92,34 @@ func (w *GenerationTaskStateCheckWorker) runOnce(parent context.Context) {
}, zap.Int("anomaly_count", count))
}
func (w *GenerationTaskStateCheckWorker) RunOnce(parent context.Context) (map[string]any, error) {
if w == nil || w.pool == nil {
return map[string]any{"skipped": true, "reason": "worker_not_ready"}, nil
}
cfg := w.runtimeConfig()
startedAt := time.Now()
count, err := CheckGenerationTaskStateConsistency(parent, w.pool, w.logger, w.cache, cfg)
duration := time.Since(startedAt)
stats := map[string]any{
"anomaly_count": count,
"duration_ms": duration.Milliseconds(),
"batch_size": cfg.BatchSize,
"lookback_sec": int64(cfg.Lookback.Seconds()),
}
if err != nil {
logCtx := tenantapp.GenerationTaskLogContext{
Stage: "state_check",
Result: tenantapp.GenerationTaskResultFailure,
Severity: "warning",
Duration: duration,
}
tenantapp.RecordGenerationTaskEvent(tenantapp.GenerationTaskEventStateCheckFailure, logCtx)
tenantapp.LogGenerationTaskWarn(w.logger, "article generation state consistency check failed", logCtx, zap.Error(err))
return stats, err
}
return stats, nil
}
func (w *GenerationTaskStateCheckWorker) runtimeConfig() generationTaskStateCheckConfig {
if w != nil && w.provider != nil {
if cfg := w.provider.Current(); cfg != nil {