Refactor duplicate functions

This commit is contained in:
TwinProduction
2021-07-16 19:51:09 -04:00
committed by Chris
parent 8b5e5f54cc
commit 627173e64f
4 changed files with 15 additions and 30 deletions

View File

@ -24,3 +24,14 @@ var (
// EventUnhealthy is a type of event that represents a service failing one or more of its conditions
EventUnhealthy EventType = "UNHEALTHY"
)
// NewEventFromResult creates an Event from a Result
func NewEventFromResult(result *Result) *Event {
event := &Event{Timestamp: result.Timestamp}
if result.Success {
event.Type = EventHealthy
} else {
event.Type = EventUnhealthy
}
return event
}