MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / Start

Method Start

internal/prd/watcher.go:45–72  ·  view source on GitHub ↗

Start begins watching the PRD file for changes.

()

Source from the content-addressed store, hash-verified

43
44// Start begins watching the PRD file for changes.
45func (w *Watcher) Start() error {
46 w.mu.Lock()
47 if w.running {
48 w.mu.Unlock()
49 return errors.New("watcher already running")
50 }
51 w.running = true
52 w.mu.Unlock()
53
54 // Load the initial PRD
55 prd, err := LoadPRD(w.path)
56 if err != nil {
57 // Don't fail startup, just send error event
58 w.events <- WatcherEvent{Error: err}
59 } else {
60 w.lastPRD = prd
61 }
62
63 // Add the file to the watcher
64 if err := w.watcher.Add(w.path); err != nil {
65 return err
66 }
67
68 // Start the event processing goroutine
69 go w.processEvents()
70
71 return nil
72}
73
74// Stop stops watching the PRD file.
75func (w *Watcher) Stop() {

Callers 8

TestWatcherStartFunction · 0.95
TestWatcherStopFunction · 0.95
InitMethod · 0.45
doStartLoopMethod · 0.45
switchToPRDMethod · 0.45

Calls 2

processEventsMethod · 0.95
LoadPRDFunction · 0.85

Tested by 5

TestWatcherStartFunction · 0.76
TestWatcherStopFunction · 0.76