2020-11-27 00:09:01 +01:00
|
|
|
package core
|
|
|
|
|
2021-02-21 00:08:00 +01:00
|
|
|
const (
|
|
|
|
// MaximumNumberOfResults is the maximum number of results that ServiceStatus.Results can have
|
2021-02-25 04:41:36 +01:00
|
|
|
MaximumNumberOfResults = 100
|
2021-02-21 00:08:00 +01:00
|
|
|
|
|
|
|
// MaximumNumberOfEvents is the maximum number of events that ServiceStatus.Events can have
|
|
|
|
MaximumNumberOfEvents = 50
|
|
|
|
)
|
|
|
|
|
2020-11-27 00:09:01 +01:00
|
|
|
// ServiceStatus contains the evaluation Results of a Service
|
|
|
|
type ServiceStatus struct {
|
2020-11-30 14:44:58 +01:00
|
|
|
// Name of the service
|
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
|
2020-11-27 00:09:01 +01: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-28 00:25:37 +01:00
|
|
|
// Key is the key representing the ServiceStatus
|
|
|
|
Key string `json:"key"`
|
|
|
|
|
2020-11-27 00:09:01 +01:00
|
|
|
// Results is the list of service evaluation results
|
|
|
|
Results []*Result `json:"results"`
|
2020-12-30 02:22:17 +01:00
|
|
|
|
2021-01-29 04:44:31 +01:00
|
|
|
// Events is a list of events
|
|
|
|
//
|
2021-02-03 05:06:34 +01:00
|
|
|
// We don't expose this through JSON, because the main dashboard doesn't need to have this data.
|
2021-01-29 04:44:31 +01: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-30 02:22:17 +01:00
|
|
|
// Uptime information on the service's uptime
|
2021-02-03 05:06:34 +01: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.
|
|
|
|
Uptime *Uptime `json:"-"`
|
2020-11-27 00:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewServiceStatus creates a new ServiceStatus
|
2021-07-14 07:53:14 +02:00
|
|
|
func NewServiceStatus(serviceKey, serviceGroup, serviceName string) *ServiceStatus {
|
2020-11-27 00:09:01 +01:00
|
|
|
return &ServiceStatus{
|
2021-07-14 07:53:14 +02:00
|
|
|
Name: serviceName,
|
|
|
|
Group: serviceGroup,
|
|
|
|
Key: serviceKey,
|
2020-11-27 00:09:01 +01:00
|
|
|
Results: make([]*Result, 0),
|
2021-07-14 07:53:14 +02:00
|
|
|
Events: make([]*Event, 0),
|
|
|
|
Uptime: NewUptime(),
|
2020-11-27 00:09:01 +01:00
|
|
|
}
|
|
|
|
}
|