mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-25 09:24:04 +01:00
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package core
|
|
|
|
// ServiceStatus contains the evaluation Results of a Service
|
|
type ServiceStatus struct {
|
|
// Name of the service
|
|
Name string `json:"name,omitempty"`
|
|
|
|
// Group the service is a part of. Used for grouping multiple services together on the front end.
|
|
Group string `json:"group,omitempty"`
|
|
|
|
// Results is the list of service evaluation results
|
|
Results []*Result `json:"results"`
|
|
|
|
// Uptime information on the service's uptime
|
|
Uptime *Uptime `json:"uptime"`
|
|
}
|
|
|
|
// NewServiceStatus creates a new ServiceStatus
|
|
func NewServiceStatus(service *Service) *ServiceStatus {
|
|
return &ServiceStatus{
|
|
Name: service.Name,
|
|
Group: service.Group,
|
|
Results: make([]*Result, 0),
|
|
Uptime: NewUptime(),
|
|
}
|
|
}
|
|
|
|
// AddResult adds a Result to ServiceStatus.Results and makes sure that there are
|
|
// no more than 20 results in the Results slice
|
|
func (ss *ServiceStatus) AddResult(result *Result) {
|
|
ss.Results = append(ss.Results, result)
|
|
if len(ss.Results) > 20 {
|
|
ss.Results = ss.Results[1:]
|
|
}
|
|
ss.Uptime.ProcessResult(result)
|
|
}
|