service

package
v0.6.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.

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) 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) Version

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

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

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

Jump to

Keyboard shortcuts

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