2024-05-10 02:56:16 +00:00
|
|
|
package endpoint
|
2020-12-30 01:22:17 +00:00
|
|
|
|
|
|
|
// Uptime is the struct that contains the relevant data for calculating the uptime as well as the uptime itself
|
2021-04-18 04:51:47 +00:00
|
|
|
// and some other statistics
|
2020-12-30 01:22:17 +00:00
|
|
|
type Uptime struct {
|
2021-04-18 04:51:47 +00:00
|
|
|
// HourlyStatistics is a map containing metrics collected (value) for every hourly unix timestamps (key)
|
2021-08-10 23:58:19 +00:00
|
|
|
//
|
|
|
|
// Used only if the storage type is memory
|
2021-04-18 04:51:47 +00:00
|
|
|
HourlyStatistics map[int64]*HourlyUptimeStatistics `json:"-"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// HourlyUptimeStatistics is a struct containing all metrics collected over the course of an hour
|
|
|
|
type HourlyUptimeStatistics struct {
|
|
|
|
TotalExecutions uint64 // Total number of checks
|
|
|
|
SuccessfulExecutions uint64 // Number of successful executions
|
2021-08-21 16:09:57 +00:00
|
|
|
TotalExecutionsResponseTime uint64 // Total response time for all executions in milliseconds
|
2020-12-30 01:22:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewUptime creates a new Uptime
|
|
|
|
func NewUptime() *Uptime {
|
|
|
|
return &Uptime{
|
2021-04-18 04:51:47 +00:00
|
|
|
HourlyStatistics: make(map[int64]*HourlyUptimeStatistics),
|
2020-12-30 01:22:17 +00:00
|
|
|
}
|
|
|
|
}
|