package api import ( "context" "database/sql" "strings" "time" "git.ryuvia.com/niklas/terdut-server/internal/config" ) // DeadmanConfig is a test fixture only: a set of matchers with one timeout and // severity, turned into switches over the API by the test helpers. Production // has no server-wide default any more -- switches belong to teams. type DeadmanConfig struct { Matchers []DeadmanMatcher Timeout time.Duration Severity string } // ParseDeadmanConfig reads a ";"-separated matcher list the way the removed // environment variable did, dropping malformed entries. func ParseDeadmanConfig(matchers string, timeout time.Duration, severity string) DeadmanConfig { cfg := DeadmanConfig{Timeout: timeout, Severity: severity} for _, entry := range strings.Split(matchers, ";") { entry = strings.TrimSpace(entry) if entry == "" { continue } if m, err := parseDeadmanMatcher(entry); err == nil { cfg.Matchers = append(cfg.Matchers, m) } } return cfg } // MetricsSweep runs one pass of the metrics worker, so a test need not wait on // its ticker. func MetricsSweep(ctx context.Context, db *sql.DB, cfg config.Config) { newMetricsService(cfg).sweep(ctx, db) }