Очередь job получила lease и fencing, телеметрия и прогресс deploy сохраняются, ревизия пишет manifest входов. Обновление префиксов не переписывает неизменённый снимок, большие наборы идут через COPY, а устаревшая ревизия не попадает в deploy. Бандл ноды кэшируется, prune и постановка job больше не держат горячий путь. Co-authored-by: Cursor <cursoragent@cursor.com>
66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strings"
|
|
"time"
|
|
|
|
"evobgp/internal/db"
|
|
"evobgp/internal/jobs"
|
|
"evobgp/internal/observability"
|
|
"evobgp/internal/pipeline"
|
|
"evobgp/internal/repository"
|
|
"evobgp/internal/store"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
)
|
|
|
|
// NewCDNHTTPClient returns the shared HTTP client for CDN and preview fetches (PERF-02 / ERR-03).
|
|
func NewCDNHTTPClient() *http.Client {
|
|
return pipeline.NewCDNHTTPClient()
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// Configured DoH profiles and RIPE service overrides retain the previous
|
|
// general HTTP/HTTPS transport, including explicitly configured private
|
|
// endpoints. CDN calls independently secure this client in UpstreamHTTPDo.
|
|
workerHTTP := pipeline.NewPipelineHTTPClient()
|
|
wk := &jobs.Worker{Store: backend, PgPool: pool, HTTPClient: workerHTTP}
|
|
reg := jobs.NewRegistry(wk.Process)
|
|
wk.Registry = reg
|
|
if pool != nil {
|
|
reg.UseDurableQueue(backend)
|
|
}
|
|
observability.RegisterStoreBackend(backend)
|
|
return backend, reg, pool, nil
|
|
}
|