Process AI jobs concurrently
All checks were successful
CI / test (push) Successful in 14s
Build and Deploy / build-and-deploy (push) Successful in 27s

This commit is contained in:
Grendgi
2026-06-08 23:38:31 +03:00
parent 89ff8dd2ff
commit 0859701ee5
2 changed files with 15 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"log/slog"
"strings"
"sync"
"time"
"ai-service/internal/llm"
@@ -94,6 +95,18 @@ func (w *Worker) tick(ctx context.Context) {
slog.Error("claim jobs failed", "error", err)
return
}
if len(jobs) > 1 {
var wg sync.WaitGroup
wg.Add(len(jobs))
for _, job := range jobs {
go func(job *model.Job) {
defer wg.Done()
w.process(ctx, job)
}(job)
}
wg.Wait()
return
}
for _, job := range jobs {
w.process(ctx, job)
}

View File

@@ -31,6 +31,8 @@ spec:
value: "llm_chat,chat_completion,call_analysis,telegram_classification"
- name: WORKER_MODEL_PROFILES
value: "qwen2.5-14b"
- name: WORKER_CLAIM_LIMIT
value: "8"
envFrom:
- configMapRef:
name: ai-service-config