Documentation
¶
Overview ¶
Package work is the engine's commands and reads on ideas and pursuits: each change one command in one transaction with its event. An idea belongs to the person who adds it and has no named states; a pursuit is started against a signal, with an appetite or none, is active, done or stopped, and an idea has at most one active pursuit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownIdea = errors.New("unknown idea") ErrUnknownPursuit = errors.New("unknown pursuit") ErrSlugTaken = errors.New("slug taken") ErrSlugInvalid = errors.New("slug invalid") ErrActivePursuit = errors.New("idea already has an active pursuit") ErrNotActive = errors.New("pursuit not active") ErrBadAppetite = errors.New("bad appetite") ErrNoPerson = errors.New("no person") ErrNoText = errors.New("no text") ErrSignal = errors.New("signal incomplete") )
The kinds of Refusal. Test one with errors.Is; the API replies bad_request to every Refusal, with its message.
Functions ¶
Types ¶
type IdeaDetail ¶
type IdeaDetail struct {
IdeaFacts
Pursuits []PursuitFacts
}
IdeaDetail is an idea with its pursuits, newest first.
type IdeaFacts ¶
type IdeaFacts struct {
Slug, Text, Person string
CreatedAt time.Time
Pursuit, PursuitState string
}
IdeaFacts is an idea and the facts that say where it stands. Pursuit and PursuitState are its latest pursuit's, empty when it has none.
type IdeaIn ¶
type IdeaIn struct {
Text, Slug, Person string
}
IdeaIn adds an idea. Slug is optional: left empty, one is made from Text.
type PursuitDetail ¶
type PursuitDetail struct {
PursuitFacts
Signal *signal.Signal
}
PursuitDetail is a pursuit with its signal, nil for a pursuit started before signals were recorded.
func StartPursuit ¶
StartPursuit starts a pursuit of an idea, with event pursuit.started carrying its appetite and signal. The signal is required whole and checked on the engine's day: its window is today or later. An appetite is optional; with none there is no circuit breaker. An idea with an active pursuit is refused another. The pursuit's slug is the idea's, numbered when an earlier pursuit has it.
func StopPursuit ¶
StopPursuit stops an active pursuit, with event pursuit.stopped. Only an active pursuit stops; the reason is kept, or "stopped by <person>" when none is given.
type PursuitFacts ¶
type PursuitFacts struct {
Slug, Idea, IdeaText, Person string
Appetite, Spent int64
State, StopReason string
CreatedAt, StartedAt time.Time
EndedAt time.Time
}
PursuitFacts is a pursuit: its idea, appetite and spend in tokens, state and times. Appetite is 0 when the pursuit has none. StopReason, StartedAt and EndedAt are empty or zero when unset.
type Refusal ¶
Refusal is a command or read refused for what it was asked, not for a fault: its message says why in plain words, naming the slug.