watch

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package watch keeps session files synced continuously. fsnotify drives prompt, debounced uploads of changed files; a periodic poll catches roots the OS watcher cannot cover (network filesystems, watch exhaustion); and a slow full rescan is the safety net for anything both missed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Debounce time.Duration // quiet period before uploading a changed file
	Poll     time.Duration // mtime/size re-stat interval for the polling fallback
	Discover time.Duration // interval to re-walk the roots for newly created files
	Rescan   time.Duration // full rediscover-and-sync safety net interval
	// Excludes are glob patterns of paths to skip (see discover.Excluder). They
	// keep an ignored location out of discovery, the poll, and event handling.
	Excludes []string
	Logf     func(string, ...any)
}

Options tune the watch timers. Zero values fall back to defaults.

type SyncFunc

type SyncFunc func(ctx context.Context, f discover.File) syncer.Result

SyncFunc syncs one file. watch depends on this rather than the concrete syncer so it can be tested without a server.

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher watches a set of roots and syncs changed session files.

func New

func New(roots []discover.Root, sync SyncFunc, opt Options) *Watcher

New builds a Watcher.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context) error

Run watches until ctx is cancelled, then returns ctx.Err(). It performs an initial full sync pass before entering the event loop.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL