Documentation
¶
Overview ¶
Package service makes every request the Go doit sends to doit's service. It is written by hand against the wire contract that the Python client keeps.
A route's call is a method on Client that names its path and the Go type of its answer. The verb needs every field that type declares without omitempty. A Go release can reach a desk before the cluster rolls the matching service. So Get refuses an answer that lacks such a field, rather than drawing it empty, and names the field and the service's version.
Index ¶
- Constants
- func ExitCode(err error) int
- func LaterSendCanStore(err error) bool
- type Client
- func (c *Client) Dashboard(ctx context.Context, lanes []string) (json.RawMessage, Dashboard, error)
- func (c *Client) Forecast(ctx context.Context, handle string) (json.RawMessage, Reading, error)
- func (c *Client) Forecasts(ctx context.Context) (json.RawMessage, []Reading, error)
- func (c *Client) Get(ctx context.Context, path string, query url.Values, answer any) (json.RawMessage, error)
- func (c *Client) Happened(ctx context.Context, since, until string) (json.RawMessage, Happened, error)
- func (c *Client) Next(ctx context.Context, machine string, reroll bool) (json.RawMessage, Next, error)
- func (c *Client) Post(ctx context.Context, path string, body any, repeatable bool, answer any) error
- func (c *Client) TakeForecast(ctx context.Context, budget *int) (json.RawMessage, Reading, error)
- func (c *Client) Today(ctx context.Context) (json.RawMessage, Today, error)
- func (c *Client) Trend(ctx context.Context, days *int) (json.RawMessage, Trend, error)
- func (c *Client) Version(ctx context.Context) (string, error)
- type Dashboard
- type DashboardLane
- type DueLane
- type ExplainRow
- type GridCell
- type Happened
- type Lane
- type LaneRow
- type MissingField
- type Next
- type NoAnswer
- type OfferRow
- type PursuitStanding
- type Quota
- type QuotaCatchUp
- type QuotaChecklist
- type QuotaUnit
- type Reading
- type ReadingRow
- type Refused
- type RegisterEntry
- type Today
- type Trend
- type TrendRow
Constants ¶
const NoAnswerExit = 4
NoAnswerExit is what a command exits with where no answer came, the one failure that the same command run later can outlast.
const Prefix = "/api/v1"
Prefix is where every route sits, the OpenAPI document among them. deploy/api.yaml names the paths the cluster routes to the service.
Variables ¶
This section is empty.
Functions ¶
func ExitCode ¶
ExitCode is what a command exits with for err: NoAnswerExit where no answer came, else 1.
func LaterSendCanStore ¶ added in v0.3.0
LaterSendCanStore is whether the same write sent later could be stored: no answer came, the login was refused, or the service broke. A refusal of the write itself is refused again however often it is sent, and an answer lacking a field came after the write was stored.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is one authenticated client of the service at base.
func New ¶
func New(base string, source oauth2.TokenSource, chosenBy, repair string) *Client
New is a client of the service at base, sending source's token. chosenBy says where base came from, and repair what fixes a refused token.
func (*Client) Dashboard ¶ added in v0.8.0
Dashboard reads every lane, or only those named in lanes, each then listing more of its rows. It answers the body it came in too.
func (*Client) Forecast ¶ added in v0.8.0
Forecast reads the reading handle names, or the newest where it is "", and answers the body it came in too.
func (*Client) Forecasts ¶ added in v0.8.0
Forecasts reads every stored reading, oldest first, and answers the body it came in too.
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, path string, query url.Values, answer any) (json.RawMessage, error)
Get reads the route at path into answer, refusing an answer that lacks a field answer's type declares without omitempty. It also answers the body as it came, for a --json that prints it whole, fields this doit does not read included.
func (*Client) Happened ¶ added in v0.8.0
func (c *Client) Happened(ctx context.Context, since, until string) (json.RawMessage, Happened, error)
Happened reads the window that since and until bound, and answers the body it came in too. Either end may be "", and the service picks the start of a window given neither end.
func (*Client) Next ¶ added in v0.7.0
func (c *Client) Next(ctx context.Context, machine string, reroll bool) (json.RawMessage, Next, error)
Next reads the draw. machine is the desk it is offered to, and reroll asks for a fresh draw though one stands. It answers the body it came in too.
func (*Client) Post ¶ added in v0.3.0
func (c *Client) Post(ctx context.Context, path string, body any, repeatable bool, answer any) error
Post sends body to the route at path and reads the answer into answer, which may be nil. The service stores a repeatable write once by the key in its body, so it is sent again after a timeout, a reset or a busy answer. Any other write is sent again only where it never reached the service.
func (*Client) TakeForecast ¶ added in v0.8.0
TakeForecast takes a forecast at budget minutes a day, or at the register's budget where budget is nil, and stores it. It answers the reading as the service sent it, for a --json that prints it whole, beside the reading read. Where the answer cannot be read, the reading is still stored, so the body comes back beside the error, and the error says so.
type Dashboard ¶ added in v0.8.0
type Dashboard struct {
GeneratedAt string `json:"generated_at"`
Lanes []DashboardLane `json:"lanes"`
// LaneNames names every lane the round built, before a lane query narrowed it.
LaneNames []string `json:"lane_names"`
Problems []string `json:"problems"`
// Configured counts the sources declared in the sources document.
Configured int `json:"configured"`
// PursuitStanding is the line naming the pursuits behind, or null where none is.
PursuitStanding *PursuitStanding `json:"pursuit_standing"`
}
Dashboard is GET /dashboard: one lane for each answer of a configured source, alert lanes first, then in the sources document's order, with doit's own maintenance lane last.
type DashboardLane ¶ added in v0.8.0
type DashboardLane struct {
Lane
RowCap int `json:"row_cap"`
// Quiet is a lane that answered with nothing open and asks not to be drawn then.
Quiet bool `json:"quiet"`
}
DashboardLane is a lane with how many of its rows the screen lists, and whether the screen leaves it out.
type DueLane ¶ added in v0.7.0
DueLane is a group of the due list, with how many of its rows the screen lists.
type ExplainRow ¶ added in v0.7.0
type ExplainRow struct {
Name string `json:"name"`
Offered bool `json:"offered"`
Skipped bool `json:"skipped"`
Weight string `json:"weight"`
Goal string `json:"goal"`
Last string `json:"last"`
Due string `json:"due"`
Pick string `json:"pick"`
// Reason is the register's reason for the pursuit, or "".
Reason string `json:"reason"`
}
ExplainRow is one pursuit's row on `doit next --explain`, each cell as it prints.
type GridCell ¶ added in v0.7.0
type GridCell struct {
Text string `json:"text"`
Done bool `json:"done"`
// Handle is what to type to act on a cell not yet done, or "".
Handle string `json:"handle"`
// DoneAt is the instant it was done, or "" where its record kept only the day.
DoneAt string `json:"done_at"`
// DoneOn is the day it was done, or "" where its record kept none.
DoneOn string `json:"done_on"`
// ActorKind is the kind of actor the service names for the cell, as
// printed, or "" where its record names nobody.
ActorKind string `json:"actor_kind"`
}
GridCell is one member of a whole set, or one thing done.
type Happened ¶ added in v0.8.0
type Happened struct {
// Since and Until are the window's ends, with the service's offset. A
// window asked with no start begins at the Unix epoch.
Since string `json:"since"`
Until string `json:"until"`
// Days is how many of the service's local days the window touches.
Days int `json:"days"`
// Asked names every group, Unavailable each that could not be read, and
// Partial each read in part.
Asked []string `json:"asked"`
Partial []string `json:"partial"`
// RecordedBy names each group whose record wrote who did each entry.
RecordedBy []string `json:"recorded_by"`
// UnknownActors counts the entries whose actor the service does not recognize.
UnknownActors int `json:"unknown_actors"`
Groups []Lane `json:"groups"`
Problems []string `json:"problems"`
}
Happened is GET /happened: what every record says happened over a window, one group per record asked.
type Lane ¶ added in v0.7.0
type Lane struct {
Name string `json:"name"`
Title string `json:"title"`
// Meta is what the heading says beside the title, such as a count, or "".
Meta string `json:"meta"`
// Status is "unavailable" where the lane could not be read, and Reason says why.
Status string `json:"status"`
// Alert is a lane that carries problems rather than work.
Alert bool `json:"alert"`
// Reason is null where the lane read whole, and says what it could not
// read where it read in part.
Reason string `json:"reason"`
Rows []LaneRow `json:"rows"`
Grid []GridCell `json:"grid"`
// Total is how many rows the lane holds before any cut.
Total int `json:"total"`
// Hints are the commands that list the rest.
Hints []string `json:"hints"`
}
Lane is one lane of the lane contract: ranked rows, or a grid of cells.
type LaneRow ¶ added in v0.7.0
type LaneRow struct {
Label string `json:"label"`
Text string `json:"text"`
Note string `json:"note"`
// Urgency is none, due or overdue, and colors the note.
Urgency string `json:"urgency"`
// Handle is the command that acts on the row.
Handle string `json:"handle"`
}
LaneRow is one thing to act on.
type MissingField ¶
type MissingField struct {
Where string
// Method is the request's, GET where it is "".
Method string
Route string
Field string
Version string
// VersionUnread is why the service's version could not be read, where it could not.
VersionUnread error
}
MissingField is an answer that lacks a field which the verb needs.
func (*MissingField) Error ¶
func (m *MissingField) Error() string
type Next ¶ added in v0.7.0
type Next struct {
DrawID string `json:"draw_id"`
// OfferRows are the offered pursuits in the draw's order, then each other
// active one, owed first.
OfferRows []OfferRow `json:"offer_rows"`
// ExplainRows are every active pursuit, owed first.
ExplainRows []ExplainRow `json:"explain_rows"`
// DrawSize is how many rows a draw fills, owed rows aside.
DrawSize int `json:"draw_size"`
// Context is today's events and near countdowns, one line each.
Context []string `json:"context"`
// ContextError is why the events could not be read, or null.
ContextError string `json:"context_error"`
// Pursuits is the register, which the names cache lists.
Pursuits map[string]RegisterEntry `json:"pursuits"`
}
Next is GET /next: the draw standing for this window, or a fresh one, with each row its screens print. The service orders and prices every row, so the screens only lay them out.
type NoAnswer ¶
type NoAnswer struct {
Message string
}
NoAnswer is no answer coming: the service was never reached, timed out, or was busy on every attempt. Run unchanged later, the same command can work.
type OfferRow ¶ added in v0.7.0
type OfferRow struct {
Name string `json:"name"`
Offered bool `json:"offered"`
Weight string `json:"weight"`
Goal string `json:"goal"`
Tally string `json:"tally"`
Due string `json:"due"`
// Late is a pursuit past its due date by a day or more.
Late bool `json:"late"`
// Choices are what an offered pursuit could be, a line each.
Choices []string `json:"choices"`
// Failed is a resolve that failed or matched nothing, which its choice says.
Failed bool `json:"failed"`
}
OfferRow is one pursuit's row on `doit next`, each cell as it prints.
type PursuitStanding ¶ added in v0.8.0
PursuitStanding is the dashboard's last line.
type Quota ¶ added in v0.7.0
type Quota struct {
// Minutes and Checkoffs are null where no pursuits were read.
Minutes *QuotaUnit `json:"minutes"`
Checkoffs *QuotaUnit `json:"checkoffs"`
CatchUp []QuotaCatchUp `json:"catch_up"`
Checklists []QuotaChecklist `json:"checklists"`
Unavailable string `json:"unavailable"`
}
Quota is the figures above both lists.
type QuotaCatchUp ¶ added in v0.7.0
type QuotaCatchUp struct {
Label string `json:"label"`
MinutesPerDay float64 `json:"minutes_per_day"`
CheckoffsPerDay float64 `json:"checkoffs_per_day"`
Shown bool `json:"shown"`
}
QuotaCatchUp is what more a day would clear the backlog over one timescale.
type QuotaChecklist ¶ added in v0.7.0
type QuotaChecklist struct {
Name string `json:"name"`
Done int `json:"done"`
Total int `json:"total"`
}
QuotaChecklist is a checklist beside the figures, or why it could not be read.
type QuotaUnit ¶ added in v0.7.0
type QuotaUnit struct {
Need float64 `json:"need"`
Done float64 `json:"done"`
Behind float64 `json:"behind"`
AskedOf int `json:"asked_of"`
}
QuotaUnit is the pursuits counted in one unit, summed.
type Reading ¶ added in v0.8.0
type Reading struct {
// Generated is when it was taken, as an ISO 8601 instant.
Generated string `json:"generated"`
Machine string `json:"machine"`
BudgetMinutes int `json:"budget_minutes"`
Replicates int `json:"replicates"`
UnspentMinutesPerDay float64 `json:"unspent_minutes_per_day"`
// Rows are each pursuit's, doing most over the month first.
Rows []ReadingRow `json:"rows"`
// Estimates says how many durations were measured and how many assumed.
Estimates string `json:"estimates"`
}
Reading is one forecast as the service answers it, with the rows its screen prints.
type ReadingRow ¶ added in v0.8.0
type ReadingRow struct {
Name string `json:"name"`
Week string `json:"week"`
Month string `json:"month"`
Hours string `json:"hours"`
// Goal is null for a reading taken before goals were recorded.
Goal *string `json:"goal"`
OfGoal string `json:"of_goal"`
// ShortOfGoal is the service judging the month short of its goal.
ShortOfGoal bool `json:"short_of_goal"`
Estimate string `json:"estimate"`
}
ReadingRow is one pursuit's row of a reading, each cell as it prints.
type RegisterEntry ¶ added in v0.7.0
type RegisterEntry struct {
Description any `json:"description,omitempty"`
}
RegisterEntry is one pursuit as the register declares it, as far as the names cache reads it.
type Today ¶ added in v0.7.0
type Today struct {
// GeneratedAt is when the service read the day, with its offset. The
// screen's date is the date there.
GeneratedAt string `json:"generated_at"`
Done []Lane `json:"done"`
Due []DueLane `json:"due"`
// Quota is null where the service drew no figures.
Quota *Quota `json:"quota"`
Problems []string `json:"problems"`
}
Today is GET /today: what the day still owes, above what it has had, in the lane contract's shape. The screens read every field it declares.
type Trend ¶ added in v0.8.0
type Trend struct {
Days int `json:"days"`
// Readings is how many readings were old enough to grade.
Readings int `json:"readings"`
// Rows are each pursuit's verdict, furthest off first.
Rows []TrendRow `json:"rows"`
}
Trend is GET /forecasts/trend: the matured readings graded at one horizon.
type TrendRow ¶ added in v0.8.0
type TrendRow struct {
Pursuit string `json:"pursuit"`
Said string `json:"said"`
Did string `json:"did"`
Error string `json:"error"`
// Missed is a prediction off by a whole occasion or more.
Missed bool `json:"missed"`
}
TrendRow is one verdict's row, each cell as it prints.