statping/types/hits/struct.go

21 lines
596 B
Go
Raw Normal View History

2020-03-04 10:29:00 +00:00
package hits
import "time"
// Hit struct is a 'successful' ping or web response entry for a service.
type Hit struct {
Id int64 `gorm:"primary_key;column:id" json:"id"`
Service int64 `gorm:"column:service" json:"-"`
2020-03-10 05:24:35 +00:00
Latency int64 `gorm:"column:latency" json:"latency"`
PingTime int64 `gorm:"column:ping_time" json:"ping_time"`
2020-03-04 10:29:00 +00:00
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
}
// BeforeCreate for Hit will set CreatedAt to UTC
func (h *Hit) BeforeCreate() (err error) {
if h.CreatedAt.IsZero() {
h.CreatedAt = time.Now().UTC()
}
return
}