diff --git a/app/reaction.go b/app/reaction.go index a892912..e052506 100644 --- a/app/reaction.go +++ b/app/reaction.go @@ -124,11 +124,13 @@ func (f *Filter) handle() chan *string { entry := LogEntry{time.Now(), match, f.stream.name, f.name, false} - f.cleanOldMatches(match) + if f.Retry > 1 { + f.cleanOldMatches(match) - f.matches[match] = append(f.matches[match], time.Now()) + f.matches[match] = append(f.matches[match], time.Now()) + } - if len(f.matches[match]) >= f.Retry { + if f.Retry <= 1 || len(f.matches[match]) >= f.Retry { entry.Exec = true delete(f.matches, match) f.execActions(match, time.Duration(0)) diff --git a/app/startup.go b/app/startup.go index 75867e3..5868eb7 100644 --- a/app/startup.go +++ b/app/startup.go @@ -78,7 +78,7 @@ func (c *Conf) setup() { stream.name = streamName if len(stream.Filters) == 0 { - log.Fatalln("FATAL Bad configuration: no filters configured in '%s'!", stream.name) + log.Fatalln("FATAL Bad configuration: no filters configured in", stream.name) } for filterName := range stream.Filters { @@ -88,14 +88,20 @@ func (c *Conf) setup() { filter.matches = make(map[string][]time.Time) // Parse Duration - retryDuration, err := time.ParseDuration(filter.RetryPeriod) - if err != nil { - log.Fatalln("FATAL Bad configuration: Failed to parse time:", err) + if filter.RetryPeriod == "" { + if filter.Retry > 1 { + log.Fatalln("FATAL Bad configuration: retry but no retry-duration in", stream.name, ".", filter.name) + } + } else { + retryDuration, err := time.ParseDuration(filter.RetryPeriod) + if err != nil { + log.Fatalln("FATAL Bad configuration: Failed to parse retry time in", stream.name, ".", filter.name, ":", err) + } + filter.retryDuration = retryDuration } - filter.retryDuration = retryDuration if len(filter.Regex) == 0 { - log.Fatalln("FATAL Bad configuration: no regexes configured in '%s.%s'!", stream.name, filter.name) + log.Fatalln("FATAL Bad configuration: no regexes configured in", stream.name, ".", filter.name) } // Compute Regexes // Look for Patterns inside Regexes @@ -123,7 +129,7 @@ func (c *Conf) setup() { } if len(filter.Actions) == 0 { - log.Fatalln("FATAL Bad configuration: no actions configured in '%s.%s'!", stream.name, filter.name) + log.Fatalln("FATAL Bad configuration: no actions configured in", stream.name, ".", filter.name) } for actionName := range filter.Actions { @@ -135,7 +141,7 @@ func (c *Conf) setup() { if action.After != "" { afterDuration, err := time.ParseDuration(action.After) if err != nil { - log.Fatalln("FATAL Bad configuration: Failed to parse time:", err) + log.Fatalln("FATAL Bad configuration: Failed to parse after time in ", stream.name, ".", filter.name, ".", action.name, ":", err) } action.afterDuration = afterDuration }