Documentation
¶
Overview ¶
Package sessionwatch polls a session's DB state and source-file mtime, emitting a tick each time the session version changes. Shared by the HTTP SSE handler and the CLI `session watch` command.
Index ¶
Constants ¶
const ( // PollInterval is how often the session monitor checks // the database for changes. PollInterval = 1500 * time.Millisecond // HeartbeatTicks is how often a keepalive is sent to // the client. Expressed as a multiple of PollInterval // (~30s). HeartbeatTicks = 20 // SyncFallbackDelay is how long to wait after detecting // a file mtime change before attempting a direct sync. // This gives the file watcher time to process the change // through the normal SyncPaths pipeline. SyncFallbackDelay = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher emits a tick on Events() each time the session's DB state changes, with an optional file-mtime-triggered direct sync when the engine is non-nil.
func New ¶
New returns a Watcher backed by the given store. engine may be nil to disable file-mtime fallback sync (PG-read mode).
func (*Watcher) Events ¶
Events polls the database for session changes and signals the returned channel when the message count changes. This is decoupled from file I/O — the file watcher handles syncing files to the database, and this monitor detects the resulting DB changes.
As a fallback when file watching or incremental sync misses a DB update, it also monitors the source file's mtime and triggers a direct sync when the DB hasn't been updated within SyncFallbackDelay.