MCPcopy Index your code
hub / github.com/php/frankenphp / InitWatcher

Function InitWatcher

internal/watcher/watcher.go:57–87  ·  view source on GitHub ↗
(ct context.Context, slogger *slog.Logger, groups []*PatternGroup)

Source from the content-addressed store, hash-verified

55}
56
57func InitWatcher(ct context.Context, slogger *slog.Logger, groups []*PatternGroup) error {
58 if len(groups) == 0 {
59 return nil
60 }
61
62 if watcherIsActive.Load() {
63 return ErrAlreadyStarted
64 }
65
66 watcherIsActive.Store(true)
67 globalCtx = ct
68 globalLogger = slogger
69
70 activeWatcher = &globalWatcher{groups: groups}
71
72 for _, g := range groups {
73 if len(g.Patterns) == 0 {
74 continue
75 }
76
77 for _, p := range g.Patterns {
78 activeWatcher.watchers = append(activeWatcher.watchers, &pattern{patternGroup: g, value: p})
79 }
80 }
81
82 if err := activeWatcher.startWatching(); err != nil {
83 return err
84 }
85
86 return nil
87}
88
89func DrainWatcher() {
90 if !watcherIsActive.Load() {

Callers 1

initWatchersFunction · 0.92

Calls 1

startWatchingMethod · 0.80

Tested by

no test coverage detected