run is a long running goroutine which watches the configured files for changes, and pushes new key material into the appropriate distributors which is returned from calls to KeyMaterial().
(ctx context.Context)
| 250 | // changes, and pushes new key material into the appropriate distributors which |
| 251 | // is returned from calls to KeyMaterial(). |
| 252 | func (w *watcher) run(ctx context.Context) { |
| 253 | ticker := time.NewTicker(w.opts.RefreshDuration) |
| 254 | for { |
| 255 | w.updateIdentityDistributor() |
| 256 | w.updateRootDistributor() |
| 257 | select { |
| 258 | case <-ctx.Done(): |
| 259 | ticker.Stop() |
| 260 | if w.identityDistributor != nil { |
| 261 | w.identityDistributor.Stop() |
| 262 | } |
| 263 | if w.rootDistributor != nil { |
| 264 | w.rootDistributor.Stop() |
| 265 | } |
| 266 | return |
| 267 | case <-ticker.C: |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | // KeyMaterial returns the key material sourced by the watcher. |
| 273 | // Callers are expected to use the returned value as read-only. |
no test coverage detected