watchd

package
v0.7.159 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package watchd implements the chunk watch background daemon and its client.

Index

Constants

View Source
const (
	// PollInterval is how often the daemon refreshes project state from disk.
	PollInterval = 5 * time.Second
	// RecentEvents is the maximum number of events kept per project.
	RecentEvents = 300
	// RunningTimeout is how long after the last non-terminal event a sidecar is
	// considered to still be running.
	RunningTimeout = 5 * time.Minute
)

Variables

This section is empty.

Functions

func EnsureDir

func EnsureDir() (string, error)

EnsureDir creates ~/.chunk/watchd/ if it doesn't exist and returns the path.

func EnsureRunning

func EnsureRunning(subArgs []string) error

EnsureRunning checks whether the watch daemon is running and serving, and launches it if not. subArgs are the CLI arguments used to invoke the daemon (e.g. ["watch", "_daemon"]).

func IsRunning

func IsRunning(path string) (bool, int, error)

IsRunning reports whether the process whose PID is stored in path is alive. Returns (false, 0, nil) when the file doesn't exist.

func LogPath

func LogPath() (string, error)

LogPath returns the path to the daemon log file.

func PIDPath

func PIDPath() (string, error)

PIDPath returns the path to the daemon PID file.

func RunDaemon

func RunDaemon(ctx context.Context) error

RunDaemon is the watch daemon entry point, called by the hidden _daemon subcommand.

func SocketPath

func SocketPath() (string, error)

SocketPath returns the path to the daemon Unix socket.

Types

type ProjectSnapshot

type ProjectSnapshot struct {
	Root     string           `json:"root"`
	Branch   string           `json:"branch"`
	HeadRef  string           `json:"head_ref"`
	RepoName string           `json:"repo_name"`
	Sidecars []SidecarState   `json:"sidecars"`
	Events   []eventlog.Event `json:"events"`
}

ProjectSnapshot is the daemon's view of one project at a point in time.

type SidecarState

type SidecarState struct {
	ID            string      `json:"id"`
	Name          string      `json:"name"`
	ProjectName   string      `json:"project_name"`
	RepoName      string      `json:"repo_name"`
	SnapshotName  string      `json:"snapshot_name"`
	FileMtime     time.Time   `json:"file_mtime"`
	LastSyncedRef string      `json:"last_synced_ref"`
	InSync        bool        `json:"in_sync"`
	LastActivity  time.Time   `json:"last_activity"`
	LastOp        eventlog.Op `json:"last_op"`
	LastLevel     string      `json:"last_level"`
	Running       bool        `json:"running"`
}

SidecarState describes one active sidecar as maintained by the daemon.

type Snapshot

type Snapshot struct {
	Projects []ProjectSnapshot `json:"projects"`
}

Snapshot is a point-in-time view of all watched projects.

func FetchSnapshot

func FetchSnapshot(roots []string) (Snapshot, error)

FetchSnapshot connects to the running watch daemon and returns the current snapshot for the given project roots. If roots is empty all known projects are returned.

Jump to

Keyboard shortcuts

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