Documentation
¶
Overview ¶
Package plan is the engine's commands and reads on a pursuit's plan and its progress: each revision kept with its reason, which change a session works on, tokens spent added and checked against the appetite in the same transaction, the circuit breaker, and the Needs you items they raise; each change one command with its event.
Index ¶
- Constants
- Variables
- func Current(db *sql.DB, session string) (slug, change string, err error)
- func Land(ctx context.Context, s work.Submitter, slug string, ...) error
- func Work(ctx context.Context, s work.Submitter, in WorkIn) error
- type ChangeSpend
- type Detail
- type Facts
- type LandedChange
- type Need
- type Revision
- type SetIn
- type SpendIn
- type SpendOut
- type WorkIn
Constants ¶
const By = "circuit breaker"
By is who stops a pursuit when its spend reaches its appetite.
Variables ¶
var ( ErrPlanInvalid = errors.New("plan invalid") ErrNoPlan = errors.New("no plan") ErrNoReason = errors.New("no reason") ErrUnknownChange = errors.New("unknown change") ErrNoSession = errors.New("no session") ErrBadTokens = errors.New("bad tokens") )
The kinds of Refusal this package adds to work's. Each is a *work.Refusal, so the API replies bad_request with its message.
Functions ¶
func Current ¶
Current returns the pursuit and planned change the session works on, read from db, a store opened read-only (store.OpenReadOnly). It never writes. No such session, or a store from before plans had changes, gives empty names and no error.
func Land ¶
func Land(ctx context.Context, s work.Submitter, slug string, landed map[string]progress.Landing) error
Land records each planned open change named in landed as landed, with event change.landed, then sets an active pursuit done, with event pursuit.done, once every change in its plan has landed. Repeating it changes nothing.
Types ¶
type ChangeSpend ¶
ChangeSpend is the tokens spent on one change; an empty Change is the pursuit itself.
type Detail ¶
type Detail struct {
Pursuit string
N, Replans int
Reason, Person string
At time.Time
Changes []plan.Change
History []Revision
}
Detail is a pursuit's current plan: its revision number, who wrote it, when and why, its changes, and how many times it was replanned. History holds every revision, oldest first, when asked for.
func Set ¶
Set stores in.Plan, already checked by internal/plan, as the pursuit's next revision with event plan.revised. Only an active pursuit takes a plan; a revision after the first needs a reason. The current plan's changes are rows; one a revision drops stays, no longer planned, with its spend.
type Facts ¶
type Facts struct {
Planned []string
Landed []LandedChange
InWork []string
AsksOpen int
Spent, Appetite int64
Replans int
PerChange []ChangeSpend
Needs []Need
}
Facts is a pursuit's progress, as facts and never one number: the changes planned, landed and in work, asks open, tokens spent against the appetite, replans, spend per change (largest first) and its open Needs you items (newest first).
type LandedChange ¶
LandedChange is a planned change that has landed on the default branch.
type SetIn ¶
SetIn stores Plan as the pursuit's next revision. Reason may be empty only for the first.
type SpendIn ¶
SpendIn reports a session's tokens on a pursuit and one of its changes (an empty Change is the pursuit itself). Tokens is the session's running total there, not an increase, so a report repeated or arriving late changes nothing.
type SpendOut ¶
SpendOut is the pursuit's spend after the report. Warned and Broke are true only when this report raised the appetite's notice or the circuit breaker.
func Spend ¶
Spend adds the increase over the session's held total to the pursuit and the change, with event spend.reported, and checks the appetite in the same transaction. On an active pursuit: the first time spend reaches 80% of the appetite the pursuit's person gets an appetite Needs you item (appetite.warned); when it reaches the appetite the circuit breaker stops the pursuit with its reason and a breaker item (pursuit.stopped), and the idea may be pursued again. A pursuit with no appetite has no notice and no circuit breaker; its spend, like spend on a done or stopped pursuit, is still recorded. No appetite is raised.