Run will block until the context is canceled. It will periodically check the health of all proxies and store the results in the cache.
(ctx context.Context)
| 127 | // Run will block until the context is canceled. It will periodically check the |
| 128 | // health of all proxies and store the results in the cache. |
| 129 | func (p *ProxyHealth) Run(ctx context.Context) { |
| 130 | ticker := time.NewTicker(p.interval) |
| 131 | defer ticker.Stop() |
| 132 | |
| 133 | for { |
| 134 | select { |
| 135 | case <-ctx.Done(): |
| 136 | return |
| 137 | case now := <-ticker.C: |
| 138 | statuses, err := p.runOnce(ctx, now) |
| 139 | if err != nil { |
| 140 | p.logger.Error(ctx, "proxy health check failed", slog.Error(err)) |
| 141 | continue |
| 142 | } |
| 143 | p.storeProxyHealth(statuses) |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | func (p *ProxyHealth) storeProxyHealth(statuses map[uuid.UUID]ProxyStatus) { |
| 149 | var proxyHosts []*agplproxyhealth.ProxyHost |
nothing calls this directly
no test coverage detected