Skip to content

Commit

Permalink
Adding more debug tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
Zohaib Sibte Hassan committed Dec 28, 2023
1 parent 6de1089 commit 11a10d9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion db/change_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,23 @@ func (conn *SqliteStreamDB) watchChanges(watcher *fsnotify.Watcher, path string)
for {
changeLogTicker.Reset()

changesPublished := false
err := conn.WithReadTx(func(_tx *sql.Tx) error {
select {
case ev, ok := <-watcher.Events:
if !ok {
return ErrEndOfWatch
}

log.Debug().Int("change", int(ev.Op)).Msg("Change detected")
if ev.Op != fsnotify.Chmod {
log.Debug().Int("change", int(ev.Op)).Msg("Change detected")
conn.publishChangeLog()
changesPublished = true
}
case <-changeLogTicker.Channel():
log.Debug().Dur("timeout", tickerDur).Msg("Change polling timeout")
conn.publishChangeLog()
changesPublished = true
}

return nil
Expand All @@ -307,6 +310,8 @@ func (conn *SqliteStreamDB) watchChanges(watcher *fsnotify.Watcher, path string)
if errWal != nil {
errWal = watcher.Add(walPath)
}

log.Debug().Bool("changes", changesPublished).Msg("Changes published")
}
}

Expand Down

0 comments on commit 11a10d9

Please sign in to comment.