44 lines
773 B
Go
44 lines
773 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 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
|
|
}
|