Documentation
¶
Overview ¶
Package watchd implements the chunk watch background daemon and its client.
Index ¶
- Constants
- func EnsureDir() (string, error)
- func EnsureRunning(subArgs []string) error
- func IsRunning(path string) (bool, int, error)
- func LogPath() (string, error)
- func PIDPath() (string, error)
- func RunDaemon(ctx context.Context) error
- func SocketPath() (string, error)
- type ProjectSnapshot
- type SidecarState
- type Snapshot
Constants ¶
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 EnsureRunning ¶
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 ¶
IsRunning reports whether the process whose PID is stored in path is alive. Returns (false, 0, nil) when the file doesn't exist.
func RunDaemon ¶
RunDaemon is the watch daemon entry point, called by the hidden _daemon subcommand.
func SocketPath ¶
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 ¶
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.