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

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
}
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
SourceID string
SourceName string
TS time.Time
Alert bool
Text string
}