f00acbc280
Replace ~150 bare status string comparisons with typed models.Status constants (StatusUp, StatusDown, StatusPending, StatusLate, StatusStale, StatusSSLExp). Single IsBroken() method replaces the duplicated isBroken lambda in monitor.go and isDown function in sla.go. Adding a new status value (e.g. DEGRADED) now requires one constant definition instead of grep-and-pray across 16 files. CheckResult.Status stays string — the checker is the boundary between raw protocol results and typed status. Cast happens at the edge in handleStatusChange.
19 lines
373 B
Go
19 lines
373 B
Go
package models
|
|
|
|
type Status string
|
|
|
|
const (
|
|
StatusUp Status = "UP"
|
|
StatusDown Status = "DOWN"
|
|
StatusPending Status = "PENDING"
|
|
StatusLate Status = "LATE"
|
|
StatusStale Status = "STALE"
|
|
StatusSSLExp Status = "SSL EXP"
|
|
)
|
|
|
|
func (s Status) IsBroken() bool {
|
|
return s == StatusDown || s == StatusSSLExp
|
|
}
|
|
|
|
func (s Status) String() string { return string(s) }
|