package api import ( "strings" "time" ) // 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 }