2020-03-04 10:29:00 +00:00
|
|
|
package failures
|
2018-09-18 22:02:27 +00:00
|
|
|
|
2020-03-04 10:29:00 +00:00
|
|
|
import "time"
|
2018-08-20 07:20:05 +00:00
|
|
|
|
2020-03-04 10:29:00 +00:00
|
|
|
const (
|
|
|
|
limitedFailures = 32
|
|
|
|
limitedHits = 32
|
2018-09-05 10:54:57 +00:00
|
|
|
)
|
2018-08-20 07:20:05 +00:00
|
|
|
|
2018-09-16 07:48:34 +00:00
|
|
|
// Failure is a failed attempt to check a service. Any a service does not meet the expected requirements,
|
2020-02-19 04:07:22 +00:00
|
|
|
// a new Failure will be inserted into Db.
|
2018-08-20 07:20:05 +00:00
|
|
|
type Failure struct {
|
2018-11-08 10:50:06 +00:00
|
|
|
Id int64 `gorm:"primary_key;column:id" json:"id"`
|
|
|
|
Issue string `gorm:"column:issue" json:"issue"`
|
|
|
|
Method string `gorm:"column:method" json:"method,omitempty"`
|
|
|
|
MethodId int64 `gorm:"column:method_id" json:"method_id,omitempty"`
|
2019-01-29 12:02:13 +00:00
|
|
|
ErrorCode int `gorm:"column:error_code" json:"error_code"`
|
2018-11-08 10:50:06 +00:00
|
|
|
Service int64 `gorm:"index;column:service" json:"-"`
|
2018-12-06 19:03:55 +00:00
|
|
|
Checkin int64 `gorm:"index;column:checkin" json:"-"`
|
2020-03-10 05:24:35 +00:00
|
|
|
PingTime int64 `gorm:"column:ping_time" json:"ping"`
|
2018-11-08 10:50:06 +00:00
|
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
2018-08-20 07:20:05 +00:00
|
|
|
}
|
|
|
|
|
2020-02-25 07:41:28 +00:00
|
|
|
type FailSort []Failure
|
2018-11-14 03:05:36 +00:00
|
|
|
|
|
|
|
func (s FailSort) Len() int {
|
|
|
|
return len(s)
|
|
|
|
}
|
|
|
|
func (s FailSort) Swap(i, j int) {
|
|
|
|
s[i], s[j] = s[j], s[i]
|
|
|
|
}
|
|
|
|
func (s FailSort) Less(i, j int) bool {
|
2020-02-25 07:41:28 +00:00
|
|
|
return s[i].Id < s[j].Id
|
2018-11-14 03:05:36 +00:00
|
|
|
}
|