feat(models): implement model.max_concurrency for background tasks

Add a new `max_concurrency` setting to the model configuration, allowing for fine-tuned control over the maximum number of concurrent background tasks (ingestion/enrichment) per model. This update includes localization support across multiple languages and integrates the setting into the system's concurrency governor, enabling immediate application of changes without requiring a service restart.
This commit is contained in:
wizardchen
2026-07-09 20:36:02 +08:00
committed by lyingbug
parent 20256287ec
commit 4404ea74e3
6 changed files with 77 additions and 0 deletions
+11
View File
@@ -28,6 +28,17 @@ func SetGovernor(l ModelConcurrencyLimiter, limit int) {
governorN = limit
}
// SetGlobalLimit updates ONLY the process-wide default per-model limit,
// leaving the installed limiter backend intact. Used by the system-settings
// runtime bridge so an operator can retune model.max_concurrency without a
// restart. A non-positive value disables the default (models that carry their
// own MaxConcurrency still honour it).
func SetGlobalLimit(limit int) {
governorMu.Lock()
defer governorMu.Unlock()
governorN = limit
}
// Gate acquires a per-model concurrency slot using the process-wide default
// limit. Equivalent to GateN(ctx, modelID, 0).
func Gate(ctx context.Context, modelID string) func() {