refactor: update worker processes in EvoBGP to accept dependencies for shared store and job registry. Enhance scheduler, ingest, render, and deploy components to utilize a unified context and improve logging for drift detection. Update architecture documentation to reflect changes in process interactions and worker functionalities.
CI / changes (push) Successful in 5s
CI / go (push) Failing after 9s
CI / openapi (push) Has been skipped
CI / bird2 (push) Has been skipped

This commit is contained in:
Denozordec
2026-04-05 17:42:07 +07:00
parent 5d21f013cf
commit b7968db4e0
22 changed files with 936 additions and 77 deletions
+25 -1
View File
@@ -2,12 +2,15 @@ package jobs
import (
"context"
"net/http"
"os"
"strings"
"time"
"evobgp/internal/birddeploy"
"evobgp/internal/birdfmt"
"evobgp/internal/observability"
"evobgp/internal/pipeline"
"evobgp/internal/store"
)
@@ -20,7 +23,17 @@ const (
// Worker executes queued jobs against store.Backend (memory or SQL).
type Worker struct {
Store store.Backend
Store store.Backend
HTTPClient *http.Client // optional; CDN refresh uses this (default 45s timeout).
}
var defaultWorkerHTTP = &http.Client{Timeout: 45 * time.Second}
func (w *Worker) httpClient() *http.Client {
if w != nil && w.HTTPClient != nil {
return w.HTTPClient
}
return defaultWorkerHTTP
}
// Process is registered as Registry.workerStart.
@@ -42,6 +55,17 @@ func (w *Worker) Process(j *Job) {
switch j.Kind {
case KindModuleRefresh:
mid, _ := j.Meta["module_id"].(string)
if strings.TrimSpace(mid) == "" {
j.Fail("missing module_id in job meta")
return
}
rev, err := pipeline.RefreshModule(context.Background(), w.Store, w.httpClient(), j.TenantID, mid)
if err != nil {
j.Fail(err.Error())
return
}
j.mergeMeta(map[string]any{"revision_id": rev})
j.Succeed()
case KindDeployApply:
w.runDeployApply(j)