TODO: how to test this?
()
| 104 | |
| 105 | // TODO: how to test this? |
| 106 | func (p *pattern) retryWatching() { |
| 107 | failureMu.Lock() |
| 108 | defer failureMu.Unlock() |
| 109 | |
| 110 | if p.failureCount >= maxFailureCount { |
| 111 | if globalLogger.Enabled(globalCtx, slog.LevelWarn) { |
| 112 | globalLogger.LogAttrs(globalCtx, slog.LevelWarn, "giving up watching", slog.String("pattern", p.value)) |
| 113 | } |
| 114 | |
| 115 | return |
| 116 | } |
| 117 | |
| 118 | if globalLogger.Enabled(globalCtx, slog.LevelInfo) { |
| 119 | globalLogger.LogAttrs(globalCtx, slog.LevelInfo, "watcher was closed prematurely, retrying...", slog.String("pattern", p.value)) |
| 120 | } |
| 121 | |
| 122 | p.failureCount++ |
| 123 | |
| 124 | p.startSession() |
| 125 | |
| 126 | // reset the failure-count if the watcher hasn't reached max failures after 5 seconds |
| 127 | go func() { |
| 128 | time.Sleep(failureResetDuration) |
| 129 | |
| 130 | failureMu.Lock() |
| 131 | if p.failureCount < maxFailureCount { |
| 132 | p.failureCount = 0 |
| 133 | } |
| 134 | failureMu.Unlock() |
| 135 | }() |
| 136 | } |
| 137 | |
| 138 | func (g *globalWatcher) startWatching() error { |
| 139 | g.events = make(chan eventHolder) |
no test coverage detected