45 lines
852 B
Go
45 lines
852 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.
|
||
|
LogAction string // Override log action.
|
||
|
AlertAction string // Override alert action.
|
||
|
}
|
||
|
|
||
|
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
|
||
|
SourceName string
|
||
|
TS time.Time
|
||
|
Alert bool
|
||
|
Text string
|
||
|
}
|