watcher

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package watcher turns file changes on the host into container actions.

The watching happens on the host, deliberately and unavoidably. The FUSE and virtiofs inotify patches were never merged, so a file edited on the host does not reliably produce an inotify event inside a container: Vite, chokidar, webpack and nodemon all miss changes made from the editor. The usual workaround is to make every watcher poll, which costs real CPU per watcher per service per bay -- five bays of a JavaScript monorepo is a fan spinning for nothing.

So devbay watches with the platform's own mechanism, on the side of the mount where it works, and tells the container what to do. That is what makes `watch:` a real field rather than a decorative one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reloader

type Reloader interface {
	Reload(ctx context.Context, service string) error
}

Reloader applies the action a changed file calls for.

type ReloaderFunc

type ReloaderFunc func(context.Context, string) error

ReloaderFunc adapts a function to Reloader.

func (ReloaderFunc) Reload

func (f ReloaderFunc) Reload(ctx context.Context, service string) error

type Watcher

type Watcher struct {

	// Log receives one line per action. Never nil after New.
	Log func(format string, args ...any)
	// contains filtered or unexported fields
}

Watcher reacts to changes under one worktree.

func New

func New(root string, m *manifest.Manifest, rel Reloader, log func(string, ...any)) (*Watcher, error)

New builds a watcher for a worktree.

func (*Watcher) Match

func (w *Watcher) Match(rel string) []string

Match reports which services care about a path, relative to the worktree.

Exported because it is the part worth testing directly: a glob that matches nothing is a watch that silently never fires, which is the failure mode this whole package exists to remove.

func (*Watcher) Run

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

Run watches until the context is cancelled.

func (*Watcher) Services

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

Services lists the services that declare a watch, sorted.

Jump to

Keyboard shortcuts

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