MCPcopy Create free account
hub / github.com/php/frankenphp / retryWatching

Method retryWatching

internal/watcher/watcher.go:106–136  ·  view source on GitHub ↗

TODO: how to test this?

()

Source from the content-addressed store, hash-verified

104
105// TODO: how to test this?
106func (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
138func (g *globalWatcher) startWatching() error {
139 g.events = make(chan eventHolder)

Callers 1

handleMethod · 0.95

Calls 2

startSessionMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected