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": {
"OK": "6h0m0s",
"Error": "6h"
"Error": "6h",
"Email": "15m"
},
"States": [
"GA"

View File

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

View File

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

View File

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