Documentation
¶
Overview ¶
Package engine is the one engine per machine: it holds the machine's lock, serves the local API on its socket, and exits when nothing is pending or when asked to stop. It never judges.
Index ¶
Constants ¶
const DefaultIdle = 30 * time.Minute
DefaultIdle is how long the engine waits with nothing pending before it exits, when Options.Idle is not set.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run is the engine: it takes the machine's lock, serves the API on the socket, opens the registered repos off the start path, and returns once ctx ends, engine.stop is called, or nothing was pending for the idle duration. Each of those returns nil. Another engine holding the lock returns *RunningError.
Types ¶
type EventOut ¶
type EventOut struct {
At string `json:"at" desc:"When the event was appended, RFC 3339 in UTC."`
Kind string `json:"kind" desc:"What happened, such as intent.done."`
Subject string `json:"subject" desc:"What it happened to, such as intent."`
Person string `json:"person,omitempty" desc:"Who made the change; left out when no person did."`
Data json.RawMessage `json:"data" desc:"The event's details, a JSON object."`
}
EventOut is one event of engine.events's output.
type EventsInput ¶
type EventsInput struct {
Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
Limit int `json:"limit,omitempty" desc:"How many of the newest events to return: 1 to 500, 50 when left out."`
}
EventsInput is engine.events's input.
type Options ¶
type Options struct {
Dir string // the settings directory, absolute
Idle time.Duration // how long to wait with nothing pending; ≤ 0 means DefaultIdle
Version string // the version engine.status reports
State state.Options // kinds (and in tests a clock) for every repo; StoreDir is set per repo
// Methods (nil by default) is how tests add methods; get opens a repo's state.
Methods func(get func(ctx context.Context, repo string) (*state.State, error)) []api.Method
}
Options say how Run serves.
type Paths ¶
type Paths struct {
Dir string // the settings directory, mode 0700
Socket string // the API's Unix socket, mode 0600
Lock string // held while the engine runs; holds its pid as text
Log string // where a detached engine's output goes
}
Paths are the engine's files in its directory.
type RunningError ¶
type RunningError struct {
PID int // the running engine's pid; 0 when it has not written it yet
}
RunningError is Run's error when another engine holds the lock.
func (*RunningError) Error ¶
func (e *RunningError) Error() string
type Status ¶
type Status struct {
Version string `json:"version" desc:"The Physa version the engine runs."`
PID int `json:"pid" desc:"The engine's OS process id."`
StartedAt string `json:"started_at" desc:"When the engine started, RFC 3339 in UTC."`
APIRevision int `json:"api_revision" desc:"The API revision the engine serves."`
Repos []string `json:"repos" desc:"The repos the engine has open."`
}
Status is engine.status's output.