internal/aggregate: make shutdown context-aware proper goroutine sync

Adds `WaitGroup` to track background goroutine and make Shutdown respect
context deadlines

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia7f074725717f037412dacb93e34105b6a6a6964
This commit is contained in:
raf 2026-03-01 20:01:32 +03:00
commit 987ddd92cc
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 205 additions and 9 deletions

View file

@ -31,9 +31,14 @@ func Run(cfg *config.Config) error {
eventRegistry := aggregate.NewCustomEventRegistry(cfg.Limits.MaxCustomEvents)
metricsAgg := aggregate.NewMetricsAggregator(pathRegistry, eventRegistry, cfg)
// HLL state persistence is handled automatically if salt_rotation is configured
// Load HLL state from previous run if it exists
if cfg.Site.SaltRotation != "" {
log.Println("HLL state persistence enabled")
if err := metricsAgg.LoadState(); err != nil {
log.Printf("Could not load HLL state (might be first run): %v", err)
} else {
log.Println("HLL state restored from previous run")
}
}
// Register Prometheus metrics