35 lines
849 B
Go
35 lines
849 B
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type StatusCode string
|
|
|
|
const (
|
|
StatusOK StatusCode = "ok" // Means - response ok, service is alive
|
|
StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down
|
|
StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched
|
|
)
|
|
|
|
type Status struct {
|
|
ID uint64 `gorm:"primary_key;auto_increment" json:"-"`
|
|
ServiceID uint64 `json:"-"`
|
|
Status StatusCode `gorm:"size:255;not null" json:"status"`
|
|
Description *string `gorm:"size:255" json:"description"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
ResponseTime uint64 `json:"responseTime"`
|
|
}
|
|
|
|
func (Status) TableName() string {
|
|
return "statuses"
|
|
}
|
|
|
|
func (s *Status) BeforeCreate(*gorm.DB) error {
|
|
s.CreatedAt = time.Now()
|
|
|
|
return nil
|
|
}
|