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
+52
View File
@@ -0,0 +1,52 @@
package httpapi
import (
"context"
"net/http"
"strings"
"time"
"evobgp/internal/db"
"evobgp/internal/jobs"
"evobgp/internal/observability"
"evobgp/internal/repository"
"evobgp/internal/store"
"github.com/jackc/pgx/v5/pgxpool"
)
// BootstrapWorkers opens the same store.Backend and jobs.Registry as New (without HTTP or bundle keys).
// Used by standalone worker binaries (scheduler, ingest, …) that share PostgreSQL with the API.
func BootstrapWorkers(ctx context.Context, opts Options) (store.Backend, *jobs.Registry, *pgxpool.Pool, error) {
ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
var backend store.Backend
var pool *pgxpool.Pool
if u := strings.TrimSpace(opts.DatabaseURL); u != "" {
p, err := db.OpenPostgresPool(ctx, u)
if err != nil {
return nil, nil, nil, err
}
pool = p
pgbe, err := repository.NewPostgres(ctx, p, opts.SeedDemo)
if err != nil {
pool.Close()
return nil, nil, nil, err
}
backend = pgbe
} else {
mem := store.NewMemory()
if opts.SeedDemo {
mem.SeedDemo()
}
backend = mem
}
cdnHTTP := &http.Client{Timeout: 45 * time.Second}
wk := &jobs.Worker{Store: backend, HTTPClient: cdnHTTP}
reg := jobs.NewRegistry(wk.Process)
observability.RegisterStoreBackend(backend)
return backend, reg, pool, nil
}