service

package
v0.7.0 Latest Latest
Warning

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

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

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

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

func ExitCode(err error) int

ExitCode is what a command exits with for err: NoAnswerExit where no answer came, else 1.

func LaterSendCanStore added in v0.3.0

func LaterSendCanStore(err error) bool

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.

func NextQuery added in v0.7.0

func NextQuery(machine string, reroll bool) url.Values

NextQuery is the query GET /next takes, which `doit next --json` sends too.

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 Open

func Open(ctx context.Context) (*Client, error)

Open is the service this machine's config file and login name.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, query url.Values, answer any) error

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

func (c *Client) Next(ctx context.Context, machine string, reroll bool) (Next, error)

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

func (c *Client) Raw(ctx context.Context, path string, query url.Values) (json.RawMessage, error)

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.

func (*Client) Today added in v0.7.0

func (c *Client) Today(ctx context.Context) (Today, error)

Today reads the day.

func (*Client) Version

func (c *Client) Version(ctx context.Context) (string, error)

Version is the service's own, from its OpenAPI document's info.version.

type DueLane added in v0.7.0

type DueLane struct {
	Lane
	RowCap int `json:"row_cap"`
}

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.

func (Lane) Available added in v0.7.0

func (l Lane) Available() bool

Available is whether the group was read.

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.

func (*NoAnswer) Error

func (n *NoAnswer) Error() string

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 says why the pursuits could not be read, or is "".
	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"`
	Unavailable string `json:"unavailable"`
}

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 Refused

type Refused struct {
	Status  int
	Message string
}

Refused is the service refusing a request, in the sentence it gave.

func (*Refused) Error

func (r *Refused) Error() string

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.

Jump to

Keyboard shortcuts

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