bugfix and new internal API

This commit is contained in:
Pierre
2026-05-25 23:47:30 +02:00
parent 415595c1c6
commit 94ad0c240b
16 changed files with 1361 additions and 2120 deletions
+14 -8
View File
@@ -68,14 +68,20 @@ func (p *Poller) Start() error {
log.Println("[WatcherPoller] Starting file watcher polling service")
// Clear file:events stream on startup to prevent duplicate events from accumulating
// across container restarts. Since in-memory state is empty, all files will be
// re-emitted as "add" events - we need a fresh stream to match.
if p.dispatcher != nil {
if err := p.dispatcher.EmitReset("startup"); err != nil {
log.Printf("[WatcherPoller] Warning: failed to clear stream on startup: %v", err)
}
}
// No startup reset. The file:events stream is bounded by MAXLEN
// (api-mediated-access PR A) and SSE consumers resume from their
// persisted Last-Event-ID, so a startup wipe would only orphan
// consumer state without buying anything. The historical reason for
// wiping — "in-memory state is empty, all files re-emit as add" —
// stopped being true when HydrateStateFromStorage landed: state is
// hydrated from Redis before this runs, so a startup EmitReset would
// tell consumers to throw out their world without sending the
// re-emission they need to rebuild it.
//
// Operator-triggered resets (POST /api/watchers/{id}/reset) still
// work — that path goes through TriggerReset, which clears both the
// stream AND the watcher's in-memory state, so the next scan tick
// emits add events for every file.
// Initial sync with watcher configurations
go p.syncWithWatchers()