diff --git a/internal/health/monitor/monitor.go b/internal/health/monitor/monitor.go index 93875115..2e019403 100644 --- a/internal/health/monitor/monitor.go +++ b/internal/health/monitor/monitor.go @@ -26,6 +26,8 @@ type ( config types.HealthCheckConfig url synk.Value[*url.URL] + onUpdateURL func(url *url.URL) + status synk.Value[types.HealthStatus] lastResult synk.Value[types.HealthCheckResult] @@ -151,6 +153,9 @@ func (mon *monitor) UpdateURL(url *url.URL) { return } mon.url.Store(url) + if mon.onUpdateURL != nil { + mon.onUpdateURL(url) + } } // URL implements HealthChecker. diff --git a/internal/health/monitor/new.go b/internal/health/monitor/new.go index dbad4260..285f081b 100644 --- a/internal/health/monitor/new.go +++ b/internal/health/monitor/new.go @@ -97,7 +97,7 @@ func NewDockerHealthMonitor(config types.HealthCheckConfig, client *docker.Share isFirstFailure := true var mon monitor - mon.init(displayURL, config, func(u *url.URL) (result Result, err error) { + mon.init(displayURL, config, func(_ *url.URL) (result Result, err error) { result, err = healthcheck.Docker(mon.Context(), state, config.Timeout) if err != nil { if isFirstFailure { @@ -106,11 +106,11 @@ func NewDockerHealthMonitor(config types.HealthCheckConfig, client *docker.Share logger.Err(err).Msg("docker health check failed, using fallback") } } - fallback.UpdateURL(u) return fallback.CheckHealth() } return result, nil }) + mon.onUpdateURL = fallback.UpdateURL return &mon }