watcher

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWatchBudget = errors.New("watch budget exhausted; observing a partial tree")

ErrWatchBudget reports that the directory cap was reached. Directories registered before the cap keep working.

Functions

This section is empty.

Types

type Ignorer

type Ignorer interface {
	Prune(path string) bool
	Ignored(ctx context.Context, path string) bool
}

Ignorer prunes paths from observation. Prune must be cheap — it is asked once per directory of a full tree walk. Ignored may consult the repository and is used only for paths that appear while the watcher is running.

type Watcher

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

func New

func New(delay time.Duration, scan func(context.Context, bool)) (*Watcher, error)

func (*Watcher) Add

func (w *Watcher) Add(root string, ignore Ignorer) error

Add watches root and its non-ignored descendants. ignore may be nil, which watches everything except .git; real workspaces must pass their repository's rules or ignored build trees pin a descriptor per file until the service exits.

func (*Watcher) Remove added in v0.1.2

func (w *Watcher) Remove(root string) int

Remove stops watching root and everything under it.

The Watcher only ever grew before this, because nothing could take a repository back: a workspace disconnected while the service was running kept a descriptor open on every directory in it - and kept waking the scanner on edits to a repository Overgent no longer coordinates - until the service was restarted. It returns how many directories it released, which is what the disconnect path reports.

Paths are taken from the backend's own watch list rather than by walking the tree again: a directory deleted since it was added still holds its descriptor, and a fresh walk would not find it to release it.

func (*Watcher) Rescan

func (w *Watcher) Rescan(ctx context.Context)

func (*Watcher) Run

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

func (*Watcher) WatchList added in v0.1.2

func (w *Watcher) WatchList() []string

WatchList reports the directories currently under watch. It exists for assertions about what a disconnect released, and for diagnostics; nothing in the service reads it to make a decision.

Jump to

Keyboard shortcuts

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