pursuits

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 14 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 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

View Source
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 Acted

func Acted(downstream map[string]any) bool

Acted is whether on_log ran, as the log's downstream records it.

func Failure

func Failure(downstream map[string]any) string

Failure is how an on_log that ran ended badly, or "" where it exited 0.

func Line

func Line(body map[string]any, logged service.Logged) string

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

func OnLogProgram(template string, fill map[string]string) (programs.Program, error)

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

func RepairLines(body map[string]any) []string

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

func WholeNumber(value any) (*int, bool)

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.

func (Entry) Body

func (e Entry) Body(namesChosen bool, chosen, downstream map[string]any) map[string]any

Body is the entry as POST /journal/done takes it. It names chosen where the check says the log names its choice, or where on_log acted on it, because otherwise the log says the pursuit happened and not which of its choices.

type HeldError

type HeldError struct {
	Err  error
	Path string
}

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.

func (*HeldError) Error

func (e *HeldError) Error() string

func (*HeldError) Unwrap

func (e *HeldError) Unwrap() error

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

func (h HeldLogs) Hold(body map[string]any) (string, error)

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.

func (HeldLogs) SendHeld

func (h HeldLogs) SendHeld(ctx context.Context, client *service.Client) ([]Sent, error)

SendHeld sends each held log again, oldest first, because an id begins with its time. It stops at the first one that gets no answer, and answers that error beside what it sent.

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

func OnLogFor(template *string, chosen map[string]any, note string, minutes *int) (*OnLog, error)

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.

func (*OnLog) Declined

func (o *OnLog) Declined() map[string]any

Declined is what the log records where the person said no to on_log.

func (*OnLog) Ran

func (o *OnLog) Ran(ctx context.Context) (map[string]any, error)

Ran runs on_log and answers what it did, as the log's downstream records it. A program that could not start ran nothing, which is an error, so nothing is logged.

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.

type Sent

type Sent struct {
	Body    map[string]any
	Logged  service.Logged
	Refused error
}

Sent is a held log that the service has now answered: stored, or refused.

Jump to

Keyboard shortcuts

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