watcher

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndexFunc

type IndexFunc func(ctx context.Context, projectName, rootPath string) error

IndexFunc is the callback signature for triggering a re-index.

type Watcher

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

Watcher polls indexed projects for file changes and triggers re-indexing. Change detection uses a 3-tier strategy per project:

  1. Git — git status + HEAD tracking (for git repos)
  2. FSNotify — event-driven via OS file notifications (for non-git dirs)
  3. Dir-mtime — directory mtime polling (fallback if fsnotify setup fails)

func New

func New(r *store.StoreRouter, indexFn IndexFunc) *Watcher

New creates a Watcher. indexFn is called when file changes are detected.

func (*Watcher) Run

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

Run blocks until ctx is cancelled. Ticks at baseInterval, polling each project only when its adaptive interval has elapsed.

func (*Watcher) Strategies

func (w *Watcher) Strategies() map[string]string

Strategies returns a snapshot of the current change-detection strategy per watched project. Useful for surfacing silent degradations (e.g., a project that probed as "git" but downgraded to "dirmtime" after git failures). Returned map is safe to mutate.

func (*Watcher) TouchProject

func (w *Watcher) TouchProject(name string)

TouchProject refreshes a project's timestamp in the watch list. If the project isn't watched yet, adds it (looks up rootPath from DB).

func (*Watcher) Unwatch

func (w *Watcher) Unwatch(name string)

Unwatch removes a project from the watch list. Called on delete.

func (*Watcher) Watch

func (w *Watcher) Watch(name, rootPath string)

Watch adds a project to the watch list. Called after successful index.

Jump to

Keyboard shortcuts

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