File size: 752 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
package heartbeat
import "fmt"
// State represents the health of a heartbeat monitor.
type State string
const (
// StateInactive means the heartbeat has not yet reported for the first time.
StateInactive State = "inactive"
// StateHealthy indicates a heartbeat was received within the past interval.
StateHealthy State = "healthy"
// StateUnhealthy indicates a heartbeat has not been received since beyond the interval.
StateUnhealthy State = "unhealthy"
)
// Scan handles reading State from the DB format
func (r *State) Scan(value interface{}) error {
switch t := value.(type) {
case []byte:
*r = State(t)
case string:
*r = State(t)
default:
return fmt.Errorf("could not process unknown type for state %T", t)
}
return nil
}
|