emailer configurable interval

master v0.0.2
Bel LaPointe 2022-01-11 07:50:58 -05:00
parent 6c455764e1
commit 27605997c1
4 changed files with 14 additions and 10 deletions

View File

@ -1,7 +1,8 @@
{ {
"Interval": { "Interval": {
"OK": "6h0m0s", "OK": "6h0m0s",
"Error": "6h" "Error": "6h",
"Email": "15m"
}, },
"States": [ "States": [
"GA" "GA"

View File

@ -11,6 +11,7 @@ import (
type Config struct { type Config struct {
Interval struct { Interval struct {
Email Duration
OK Duration OK Duration
Error Duration Error Duration
} }

17
main.go
View File

@ -21,16 +21,15 @@ var stateFinder = regexp.MustCompile(`[A-Za-z]+`)
func main() { func main() {
lock := &sync.Mutex{} lock := &sync.Mutex{}
go func() { go func() {
c := time.NewTicker(time.Minute) for {
for range c.C { if config.Get().EmailerEnabled {
if !config.Get().EmailerEnabled { lock.Lock()
continue if err := email(); err != nil {
log.Print(err)
}
lock.Unlock()
} }
lock.Lock() time.Sleep(config.Get().Interval.Email.Get())
if err := email(); err != nil {
log.Print(err)
}
lock.Unlock()
} }
}() }()
if err := _main(); err != nil { if err := _main(); err != nil {

View File

@ -4,7 +4,10 @@ todo:
- banlist criteria like vendors, brokers, metadata - banlist criteria like vendors, brokers, metadata
- quiet hours - quiet hours
- setup pa on element - setup pa on element
- accept states via element for one system
done: done:
- configurable email interval
- jitter on intervals, including dedicated err span
- email doesnt get all matches - email doesnt get all matches
- send jobs - send jobs
- read jobs - read jobs