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
- func NextQuery(machine string, reroll bool) url.Values
- type Client
- func (c *Client) Get(ctx context.Context, path string, query url.Values, answer any) error
- func (c *Client) Next(ctx context.Context, machine string, reroll bool) (Next, error)
- func (c *Client) Post(ctx context.Context, path string, body any, repeatable bool, answer any) error
- func (c *Client) Raw(ctx context.Context, path string, query url.Values) (json.RawMessage, error)
- func (c *Client) Today(ctx context.Context) (Today, error)
- func (c *Client) Version(ctx context.Context) (string, error)
- type DueLane
- type ExplainRow
- type GridCell
- type Lane
- type LaneRow
- type MissingField
- type Next
- type NoAnswer
- type OfferRow
- type Quota
- type QuotaCatchUp
- type QuotaChecklist
- type QuotaUnit
- type Refused
- type RegisterEntry
- type Today
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.
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) Get ¶
Get reads the route at path into answer, refusing an answer that lacks a field answer's type declares without omitempty.
func (*Client) Next ¶ added in v0.7.0
Next reads the draw. machine is the desk it is offered to, and reroll asks for a fresh draw though one stands.
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) Raw ¶ added in v0.7.0
Raw is the route's answer at path as it came, for a --json that prints it whole. It refuses only an answer that is not JSON, because a field this doit does not read is the reader's own.
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"`
// DoneAt is the instant it was done, or "" where its record kept only the day.
DoneAt string `json:"done_at"`
// 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 thing done.
type Lane ¶ added in v0.7.0
type Lane struct {
Name string `json:"name"`
// Status is "unavailable" where the group could not be read, and Reason says why.
Status string `json:"status"`
// Reason is null where the group 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 group holds before any cut.
Total int `json:"total"`
Hints []string `json:"hints"`
}
Lane is one group of a list: ranked rows, or a grid of finished 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
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 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 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. It declares only the fields the screen reads.