This repository has been archived on 2019-06-27. You can view files and clone it, but cannot push or open issues/pull-requests.
am/types.go

45 lines
798 B
Go
Raw Normal View History

2019-06-10 17:09:10 +00:00
package am
import "time"
type User struct {
Username string
Admin bool
}
type Source struct {
SourceID string
Name string
APIKey string
Description string
LastSeenAt time.Time
AlertTimeout int64 // In seconds.
AlertedAt time.Time // Timeout alert time.
}
func (s Source) TimedOut() bool {
return s.AlertTimeout != 0 &&
time.Since(s.LastSeenAt) > time.Duration(s.AlertTimeout)*time.Second
2019-06-10 17:09:10 +00:00
}
func (s Source) RequiresAlertForTimeout() bool {
return s.TimedOut() && s.AlertedAt.Before(s.LastSeenAt)
}
type Entry struct {
LogID int64
SourceID string
TS time.Time
Alert bool
Text string
}
type EntryListRow struct {
LogID int64
2019-06-11 07:44:35 +00:00
SourceID string
2019-06-10 17:09:10 +00:00
SourceName string
TS time.Time
Alert bool
Text string
}