diff options
Diffstat (limited to 'internal/monitor/scheduler.go')
| -rw-r--r-- | internal/monitor/scheduler.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/internal/monitor/scheduler.go b/internal/monitor/scheduler.go index 7a06131..5a7e817 100644 --- a/internal/monitor/scheduler.go +++ b/internal/monitor/scheduler.go @@ -100,7 +100,36 @@ func (s *Scheduler) executeCheck(mon Monitor) { checkCtx, cancel := context.WithTimeout(s.ctx, mon.Interval()) defer cancel() - result := mon.Check(checkCtx) + var result *Result + retries := mon.Retries() + + // Try the check, with retries if configured + for attempt := 0; attempt <= retries; attempt++ { + result = mon.Check(checkCtx) + + // If check succeeded (up or degraded), no need to retry + if result.Status == StatusUp || result.Status == StatusDegraded { + break + } + + // If this wasn't the last attempt, log and retry + if attempt < retries { + s.logger.Debug("check failed, retrying", + "name", mon.Name(), + "attempt", attempt+1, + "max_retries", retries, + "error", result.Error) + + // Small delay before retry (500ms) + select { + case <-checkCtx.Done(): + // Context cancelled, abort retries + break + case <-time.After(500 * time.Millisecond): + // Continue to next retry + } + } + } // Log the result logAttrs := []any{ |