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.
This commit is contained in:
+33
-4
@@ -1,22 +1,51 @@
|
||||
// Package ingest fetches CDN lists, resolves DoH domains, and writes normalized prefixes into the database.
|
||||
package ingest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"evobgp/internal/broker"
|
||||
"evobgp/internal/config"
|
||||
"evobgp/internal/pipeline"
|
||||
"evobgp/internal/store"
|
||||
)
|
||||
|
||||
// Run blocks until ctx is cancelled. Reference deployment: separate process consuming the job queue.
|
||||
func Run(ctx context.Context) {
|
||||
// Deps runs lightweight CDN ETag prefetch against the shared store.
|
||||
type Deps struct {
|
||||
Store store.Backend
|
||||
}
|
||||
|
||||
// Run blocks until ctx is cancelled.
|
||||
func Run(ctx context.Context, deps *Deps) {
|
||||
cfg := config.Load()
|
||||
broker.LogConnect(ctx, cfg.BrokerURL)
|
||||
if deps == nil || deps.Store == nil {
|
||||
runStub(ctx)
|
||||
return
|
||||
}
|
||||
hc := &http.Client{Timeout: 45 * time.Second}
|
||||
t := time.NewTicker(60 * time.Second)
|
||||
defer t.Stop()
|
||||
log.Printf("evobgp-ingest: started (stub; ingest workers dequeue from broker or job_audit)")
|
||||
log.Printf("evobgp-ingest: active (CDN conditional GET / ETag prefetch)")
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Printf("evobgp-ingest: stopped")
|
||||
return
|
||||
case <-t.C:
|
||||
if err := pipeline.PrefetchCDNSourceETags(context.Background(), deps.Store, hc); err != nil {
|
||||
log.Printf("evobgp-ingest: prefetch: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runStub(ctx context.Context) {
|
||||
t := time.NewTicker(60 * time.Second)
|
||||
defer t.Stop()
|
||||
log.Printf("evobgp-ingest: idle stub (no store in Deps)")
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
||||
Reference in New Issue
Block a user