Files
gatus/core/service_status.go
T

46 lines
1.6 KiB
Go
Raw Normal View History

2020-11-26 18:09:01 -05:00
package core
// ServiceStatus contains the evaluation Results of a Service
type ServiceStatus struct {
// Name of the service
Name string `json:"name,omitempty"`
2020-11-26 18:09:01 -05:00
// Group the service is a part of. Used for grouping multiple services together on the front end.
Group string `json:"group,omitempty"`
2021-01-27 18:25:37 -05:00
// Key is the key representing the ServiceStatus
Key string `json:"key"`
2020-11-26 18:09:01 -05:00
// Results is the list of service evaluation results
Results []*Result `json:"results"`
2020-12-29 20:22:17 -05:00
2021-01-28 22:44:31 -05:00
// Events is a list of events
//
2021-02-02 23:06:34 -05:00
// We don't expose this through JSON, because the main dashboard doesn't need to have this data.
2021-01-28 22:44:31 -05:00
// However, the detailed service page does leverage this by including it to a map that will be
// marshalled alongside the ServiceStatus.
Events []*Event `json:"-"`
2020-12-29 20:22:17 -05:00
// Uptime information on the service's uptime
2021-02-02 23:06:34 -05:00
//
// We don't expose this through JSON, because the main dashboard doesn't need to have this data.
// However, the detailed service page does leverage this by including it to a map that will be
// marshalled alongside the ServiceStatus.
2021-08-12 21:54:23 -04:00
//
// TODO: Get rid of this in favor of using the new store.GetUptimeByKey.
// TODO: For memory, store the uptime in a different map? (is that possible, given that we need to persist it through gocache?)
// Deprecated
2021-02-02 23:06:34 -05:00
Uptime *Uptime `json:"-"`
2020-11-26 18:09:01 -05:00
}
// NewServiceStatus creates a new ServiceStatus
2021-07-14 01:53:14 -04:00
func NewServiceStatus(serviceKey, serviceGroup, serviceName string) *ServiceStatus {
2020-11-26 18:09:01 -05:00
return &ServiceStatus{
2021-07-14 01:53:14 -04:00
Name: serviceName,
Group: serviceGroup,
Key: serviceKey,
2020-11-26 18:09:01 -05:00
Results: make([]*Result, 0),
2021-07-14 01:53:14 -04:00
Events: make([]*Event, 0),
Uptime: NewUptime(),
2020-11-26 18:09:01 -05:00
}
}