package check import ( "context" "encoding/json" ) // HeartbeatConfig configures a heartbeat monitor. type HeartbeatConfig struct { // GraceSeconds is how late a ping may be before the monitor counts as // failed, to absorb jobs that run a little longer than usual. GraceSeconds int `json:"grace_seconds"` } // DefaultHeartbeatGrace applies when no grace period is set. const DefaultHeartbeatGrace = 60 type heartbeatCheck struct{} func (heartbeatCheck) validate(_ string, config json.RawMessage) (json.RawMessage, error) { c, err := decode[HeartbeatConfig](config) if err != nil { return nil, err } if c.GraceSeconds == 0 { c.GraceSeconds = DefaultHeartbeatGrace } if c.GraceSeconds < 0 || c.GraceSeconds > 86400 { return nil, invalid("invalid_grace") } return encode(c), nil } func (heartbeatCheck) run(context.Context, Spec) Outcome { return Outcome{Error: "heartbeat monitors are not run by checkers"} }