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
+3
View File
@@ -83,6 +83,7 @@ func main() {
kolSubscriptionsRepo := repository.NewKolSubscriptionRepository(pool)
auditsRepo := repository.NewAuditRepository(pool)
siteDomainMappingsRepo := repository.NewSiteDomainMappingRepository(monitoringPool)
schedulerRepo := repository.NewSchedulerRepository(pool)
ipRegionResolver, err := ipregion.NewResolver(cfg.IPRegion.V4XDBPath, cfg.IPRegion.V6XDBPath, logger)
if err != nil {
@@ -118,6 +119,7 @@ func main() {
kolSubscriptionSvc := app.NewKolSubscriptionService(kolSubscriptionsRepo, auditSvc).WithCache(appCache)
siteDomainMappingSvc := app.NewSiteDomainMappingService(siteDomainMappingsRepo, auditSvc)
complianceSvc := app.NewComplianceService(pool, auditSvc, logger)
schedulerSvc := app.NewSchedulerService(schedulerRepo, auditSvc)
if err := app.SeedDefaultAdmin(ctx, accountsRepo, app.DefaultAdminSeed{
Username: cfg.DefaultAdmin.Username,
@@ -165,6 +167,7 @@ func main() {
Audits: auditSvc,
SiteDomains: siteDomainMappingSvc,
Compliance: complianceSvc,
Scheduler: schedulerSvc,
})
addr := fmt.Sprintf(":%d", cfg.Server.Port)
+52 -7
View File
@@ -95,14 +95,59 @@ func main() {
generationStateCheckWorker := generateworker.NewGenerationTaskStateCheckWorker(app.DB, app.Logger, app.Config().Generation).
WithConfigProvider(app.ConfigStore).
WithCache(app.Cache)
monitoringRetentionWorker := internalscheduler.NewMonitoringRetentionWorker(app.MonitoringDB, app.Logger)
startSchedulerWorker(ctx, &workerWG, "schedule_dispatch", app.Logger.Sugar(), scheduleDispatchWorker.Run)
startSchedulerWorker(ctx, &workerWG, "monitoring_daily_task", app.Logger.Sugar(), monitoringDailyTaskWorker.Run)
startSchedulerWorker(ctx, &workerWG, "monitoring_result_recovery", app.Logger.Sugar(), monitoringResultRecoveryWorker.Run)
startSchedulerWorker(ctx, &workerWG, "monitoring_lease_recovery", app.Logger.Sugar(), monitoringLeaseRecoveryWorker.Run)
startSchedulerWorker(ctx, &workerWG, "monitoring_received_inspection", app.Logger.Sugar(), monitoringReceivedInspectionWorker.Run)
startSchedulerWorker(ctx, &workerWG, "knowledge_deleted_cleanup", app.Logger.Sugar(), knowledgeDeletedCleanupWorker.Run)
startSchedulerWorker(ctx, &workerWG, "generation_state_check", app.Logger.Sugar(), generationStateCheckWorker.Run)
controlPlane := internalscheduler.NewControlPlane(app.DB, app.Logger, []internalscheduler.ControlledJob{
{
Key: "schedule_dispatch",
Run: func(runCtx context.Context, _ internalscheduler.JobRunContext) (map[string]any, error) {
return scheduleDispatchWorker.RunOnce(runCtx)
},
},
{
Key: "monitoring_daily_task",
Run: func(runCtx context.Context, _ internalscheduler.JobRunContext) (map[string]any, error) {
return monitoringDailyTaskWorker.RunOnce(runCtx)
},
},
{
Key: "monitoring_result_recovery",
Run: func(runCtx context.Context, _ internalscheduler.JobRunContext) (map[string]any, error) {
return monitoringResultRecoveryWorker.RunOnce(runCtx)
},
},
{
Key: "monitoring_lease_recovery",
Run: func(runCtx context.Context, _ internalscheduler.JobRunContext) (map[string]any, error) {
return monitoringLeaseRecoveryWorker.RunOnce(runCtx)
},
},
{
Key: "monitoring_received_inspection",
Run: func(runCtx context.Context, _ internalscheduler.JobRunContext) (map[string]any, error) {
return monitoringReceivedInspectionWorker.RunOnce(runCtx)
},
},
{
Key: "knowledge_deleted_cleanup",
Run: func(runCtx context.Context, _ internalscheduler.JobRunContext) (map[string]any, error) {
return knowledgeDeletedCleanupWorker.RunOnce(runCtx)
},
},
{
Key: "generation_state_check",
Run: func(runCtx context.Context, _ internalscheduler.JobRunContext) (map[string]any, error) {
return generationStateCheckWorker.RunOnce(runCtx)
},
},
{
Key: "monitoring_retention_cleanup",
Run: func(runCtx context.Context, jobCtx internalscheduler.JobRunContext) (map[string]any, error) {
return monitoringRetentionWorker.RunOnce(runCtx, jobCtx)
},
},
})
startSchedulerWorker(ctx, &workerWG, "control_plane", app.Logger.Sugar(), controlPlane.Run)
var metricsServer *http.Server
if app.Config().Scheduler.HTTPPort > 0 {