daemon

package
v0.102.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package daemon owns the durable local lifecycle record for the WB daemon.

The record deliberately contains scheduler ownership, rather than command output, so a later ConnectRPC/gRPC transport and the MCP adapter can use the same queue handoff contract without reading a dashboard-only file.

Index

Constants

View Source
const (
	StateSchemaVersion = 1
	QueueSchemaVersion = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Provenance

type Provenance struct {
	Executable string `json:"executable"`
	SHA256     string `json:"sha256"`
	Version    string `json:"version"`
	Revision   string `json:"revision,omitempty"`
	Built      string `json:"built,omitempty"`
}

Provenance identifies the exact executable trusted to own a daemon generation. SHA256 is intentionally included even when the released version is known: a development binary can otherwise look identical to a release.

func ProvenanceForExecutable

func ProvenanceForExecutable(executable, version, revision, built string) (Provenance, error)

ProvenanceForExecutable produces exact local evidence for a running binary.

func (Provenance) SameBinary

func (p Provenance) SameBinary(other Provenance) bool

type Queue

type Queue struct {
	SchemaVersion int         `json:"schema_version"`
	Generation    uint64      `json:"generation"`
	Owner         Provenance  `json:"owner"`
	OwnerToken    string      `json:"owner_token"`
	HandoffFrom   *Provenance `json:"handoff_from,omitempty"`
	HandoffAt     *time.Time  `json:"handoff_at,omitempty"`
}

Queue describes durable queue ownership. Operations are added by the async scheduler lane; lifecycle code preserves this object byte-for-byte apart from a fenced owner/generation transition.

type State

type State struct {
	SchemaVersion int        `json:"schema_version"`
	Status        Status     `json:"status"`
	PID           int        `json:"pid,omitempty"`
	OwnerToken    string     `json:"owner_token,omitempty"`
	Listen        string     `json:"listen"`
	Provenance    Provenance `json:"provenance"`
	Queue         Queue      `json:"queue"`
	StartedAt     time.Time  `json:"started_at,omitempty"`
	UpdatedAt     time.Time  `json:"updated_at"`
}

State is private local state. It is never served by the dashboard API.

func NewStarting

func NewStarting(previous *State, listen string, provenance Provenance, ownerToken string, now time.Time) State

NewStarting creates the next fenced queue generation. Existing queue jobs stay in the durable queue file owned by the scheduler; this record tells the replacement scheduler exactly which binary owned the preceding generation.

func (*State) MarkDraining

func (s *State) MarkDraining(now time.Time)

func (*State) MarkReady

func (s *State) MarkReady(pid int, now time.Time)

func (*State) MarkStopped

func (s *State) MarkStopped(now time.Time)

func (State) Valid

func (s State) Valid() error

type Status

type Status string
const (
	StatusStarting Status = "starting"
	StatusReady    Status = "ready"
	StatusDraining Status = "draining"
	StatusStopped  Status = "stopped"
)

type Store

type Store struct{ Path string }

Store reads and atomically replaces the local state record. Its directory and file permissions keep operation/queue metadata per-user on Unix; the Windows service adapter will use the current-user application-data ACL.

func (Store) Load

func (s Store) Load() (State, bool, error)

func (Store) Save

func (s Store) Save(state State) error

Jump to

Keyboard shortcuts

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