Documentation
¶
Overview ¶
Package pursuits logs a pursuit as the service checks it: the choice that the log is about, its on_log run on this desk, and the journal entry that records both. `doit pursuits log` and the desk nudge watch's pick each log through it, so the service's rules reach both the same way.
Index ¶
- Constants
- func Acted(downstream map[string]any) bool
- func Failure(downstream map[string]any) string
- func Line(body map[string]any, logged service.Logged) string
- func Log(ctx context.Context, client *service.Client, run Run) (map[string]any, service.Logged, error)
- func OnLogProgram(template string, fill map[string]string) (programs.Program, error)
- func RepairLines(body map[string]any) []string
- func WholeNumber(value any) (*int, bool)
- type Entry
- type HeldError
- type HeldLogs
- type OnLog
- type Run
- type Sent
Constants ¶
const OnLogBound = 30 * time.Second
OnLogBound is how long a pursuit's on_log may take. It completes one item in another app, which may wait on that app's network.
Variables ¶
This section is empty.
Functions ¶
func Line ¶
Line is what a log says once it lands: the pursuit, the choice it names, and when it next comes due.
func Log ¶
func Log(ctx context.Context, client *service.Client, run Run) (map[string]any, service.Logged, error)
Log runs the pursuit's on_log where Approve agrees, then posts the entry that records what it did. It answers the body it posted. Where no answer says the entry was stored, it stays held, and the error is a *HeldError.
func OnLogProgram ¶
OnLogProgram is a pursuit's on_log as an argv. The template is split into arguments first, then each placeholder is filled in, so a label holding a space or a quote stays one argument.
func RepairLines ¶
RepairLines say what on_log already did, and the log that records the entry without running on_log again, for an entry the service never took.
func WholeNumber ¶
WholeNumber reads a whole number from an entry, which holds an int as built and a float64 once read back from JSON.
Types ¶
type Entry ¶
type Entry struct {
// ID keys the entry, so the service stores a resend once.
ID string
Pursuit string
Occurred time.Time
Note string
Minutes *int
Machine string
Actor string
}
Entry is one log of a pursuit, as this desk writes it.
type HeldError ¶
HeldError is a log that got no answer saying it was stored. Its entry is held at Path, and the next log of any pursuit on this desk sends it again.
type HeldLogs ¶
type HeldLogs struct {
Dir string
}
HeldLogs is a directory of logs sent from this desk and not yet seen stored, one file per entry, named by its id. A log is held from just before its post until the service answers it. When an answer is lost after on_log acted, the entry is sent again under its own id, so the service stores it once and on_log never runs twice.
func DeskHeldLogs ¶
func DeskHeldLogs() HeldLogs
DeskHeldLogs are this desk's, under $XDG_STATE_HOME.
func (HeldLogs) Hold ¶
Hold keeps body on this desk until a send of it is answered, and answers where.
func (HeldLogs) Post ¶
func (h HeldLogs) Post(ctx context.Context, client *service.Client, body map[string]any) (service.Logged, error)
Post holds body while it posts it. An entry the service stores, or refuses, is let go, because a later send changes neither. Any other failure keeps it, and answers a *HeldError.
type OnLog ¶
type OnLog struct {
Program programs.Program
// Command is the argv as a shell would read it, which the log records.
Command string
}
OnLog is a pursuit's on_log filled in for one choice, ready to run.
func OnLogFor ¶
OnLogFor is template filled in for chosen, or nil where nothing runs: no template, no choice, or an {id} that the choice does not carry.
type Run ¶
type Run struct {
Check service.LogCheck
// Chosen is what the log is about: the check's choice, or the person's pick.
Chosen map[string]any
// Entry is the log's fields. Its instant is the one the check fixed.
Entry Entry
// Approve says whether on_log runs and, where it does not, what the log
// records instead. A nil Approve runs it unasked.
Approve func(*OnLog) (run bool, instead map[string]any)
// Started keeps the entry as on_log begins, saying it may not have run.
// An error stops the log before on_log runs.
Started func(body map[string]any) error
// Ended keeps the entry once on_log has ended.
Ended func(body map[string]any)
// Held keeps the entry on this desk until the service answers it.
Held HeldLogs
}
Run is one log of a pursuit once the service's check has passed. A caller asks the person what the check leaves open, and fills in the rest.