Split AI service worker task queues
All checks were successful
CI / test (push) Successful in 15s
Build and Deploy / build-and-deploy (push) Successful in 27s

This commit is contained in:
Grendgi
2026-06-08 15:57:38 +03:00
parent 33317cf20d
commit 039bcdb2b2
4 changed files with 109 additions and 28 deletions

View File

@@ -3,6 +3,7 @@ package config
import (
"os"
"strconv"
"strings"
"time"
)
@@ -20,10 +21,12 @@ type Config struct {
WhisperXURL string
WhisperXTimeout time.Duration
WorkerID string
WorkerPollInterval time.Duration
WorkerClaimLimit int
WorkerLeaseTimeout time.Duration
WorkerID string
WorkerPollInterval time.Duration
WorkerClaimLimit int
WorkerLeaseTimeout time.Duration
WorkerTaskTypes []string
WorkerModelProfiles []string
}
func Load() Config {
@@ -41,10 +44,12 @@ func Load() Config {
WhisperXURL: envString("WHISPERX_URL", ""),
WhisperXTimeout: envDuration("WHISPERX_TIMEOUT", 10*time.Minute),
WorkerID: envString("WORKER_ID", hostname()),
WorkerPollInterval: envDuration("WORKER_POLL_INTERVAL", 2*time.Second),
WorkerClaimLimit: envInt("WORKER_CLAIM_LIMIT", 4),
WorkerLeaseTimeout: envDuration("WORKER_LEASE_TIMEOUT", 15*time.Minute),
WorkerID: envString("WORKER_ID", hostname()),
WorkerPollInterval: envDuration("WORKER_POLL_INTERVAL", 2*time.Second),
WorkerClaimLimit: envInt("WORKER_CLAIM_LIMIT", 4),
WorkerLeaseTimeout: envDuration("WORKER_LEASE_TIMEOUT", 15*time.Minute),
WorkerTaskTypes: envCSV("WORKER_TASK_TYPES"),
WorkerModelProfiles: envCSV("WORKER_MODEL_PROFILES"),
}
}
@@ -91,6 +96,21 @@ func envDuration(key string, fallback time.Duration) time.Duration {
return v
}
func envCSV(key string) []string {
raw := strings.TrimSpace(os.Getenv(key))
if raw == "" {
return nil
}
parts := strings.Split(raw, ",")
out := make([]string, 0, len(parts))
for _, part := range parts {
if v := strings.TrimSpace(part); v != "" {
out = append(out, v)
}
}
return out
}
func hostname() string {
h, err := os.Hostname()
if err != nil || h == "" {