feat(scheduler): random run-window scheduling and deduped manual triggers
Support a random daily run window (random_window_start/end) where the next auto-run time is derived from a stable per-job hash, avoiding thundering-herd starts while keeping one run per day. Honors the last auto-run on initial scheduling so restarts don't double-fire. Manual triggers can opt into dedupe (dedupe_manual_triggers): an advisory-locked path collapses concurrent requests onto an existing pending/running job instead of queueing duplicates. Scheduler error messages are localized to Chinese. Register the media_supply_cache_sync job (dry-run aware) and add the ops migration that seeds it.
This commit is contained in:
@@ -181,6 +181,19 @@ func main() {
|
||||
return schedulerRunRetentionWorker.RunOnce(runCtx, jobCtx)
|
||||
},
|
||||
},
|
||||
{
|
||||
Key: "media_supply_cache_sync",
|
||||
Run: func(runCtx context.Context, jobCtx internalscheduler.JobRunContext) (map[string]any, error) {
|
||||
modelID := internalscheduler.AsInt(jobCtx.Config, "model_id", 1)
|
||||
if jobCtx.DryRun {
|
||||
return map[string]any{
|
||||
"model_id": modelID,
|
||||
"synced": 0,
|
||||
}, nil
|
||||
}
|
||||
return app.MediaSupplyService.RunMediaResourceSyncOnce(runCtx, modelID)
|
||||
},
|
||||
},
|
||||
})
|
||||
startSchedulerWorker(ctx, &workerWG, "control_plane", app.Logger.Sugar(), controlPlane.Run)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user