feat(monitors): public heartbeat ping endpoints, header token, log masking and sweeper
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
// Package metricsched sweeps passive monitors - heartbeats and, from phase 2,
|
||||
// metric monitors - on a fixed tick. Nothing here runs a check: it reads what
|
||||
// pings and agents already delivered and decides what is overdue or breaching.
|
||||
package metricsched
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"gitea.hostxtra.co.uk/mrhid6/vantage/server/internal/services"
|
||||
)
|
||||
|
||||
const tick = 30 * time.Second
|
||||
|
||||
func Start(ctx context.Context) {
|
||||
go func() {
|
||||
t := time.NewTicker(tick)
|
||||
defer t.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case now := <-t.C:
|
||||
sweep(now)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// sweep recovers per sweep so one bad document cannot stop alerting for the
|
||||
// whole instance until the next deploy.
|
||||
func sweep(now time.Time) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("metricsched: sweep panic: %v", r)
|
||||
}
|
||||
}()
|
||||
services.SweepHeartbeats(now)
|
||||
}
|
||||
Reference in New Issue
Block a user