Documentation
¶
Overview ¶
Package sprintwire is how a worker talks to the sprint's server: the run loop on the coordinator's machine, the one writer of the sprint, which runs a worker's verbs for it, one at a time, beside the store. The server is single threaded and runs each request's batch in order, a plain client/server pair carries the verbs rather than a shared store, and both ends are Go. A request is the worker's verbs, each the argument list it would give nova-sprint, in the order to run them; the reply is each verb's exit code and what it printed. One request is one exchange whatever it carries, from beside the server or from 100 ms away.
Index ¶
Constants ¶
const ( MaxRequest = 1 << 20 MaxVerbs = 256 )
MaxRequest bounds a request's body, and MaxVerbs the verbs of one batch.
const Path = "/verbs"
Path is the server's one endpoint.
const Timeout = 2 * time.Minute
Timeout is how long a client waits for the server's answer by default.
const Tries = 3
Tries is how many times a verb is sent when the server does not answer. A write carries one operation id through them, so one that ran and whose answer was lost returns its recorded result and changes nothing twice.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Answer ¶ added in v1.2.14
type Answer int
Answer is what a verb's run says became of its write, beside its exit code.
const ( // Accepted is exit 0: the server answered and the verb did what it named. Accepted Answer = iota // Refused is a non-zero exit the server answered for a write that did not // happen: a card refused (stepExit 1), a usage or epoch refusal before the // store was touched (refuse(), exit 2, "nova-sprint <verb> REFUSED:"), a // worker verb the server will not serve, a pending operation, a cleared // epoch that changed nothing. Refused // Unknown is a write whose outcome is not known: no try reached the server // (the 2 is this worker's own), or the server answered that the store did not // confirm it (ErrUnknown, changed=unknown), that its operation was cut after // an earlier manifest applied (CutError, fenced for nova-sprint repair), or // that it finished at an epoch a clear closed. Unknown )
type Client ¶
type Client struct {
Addr string // host:port
HTTP *http.Client // nil is a client that waits Timeout for an answer
}
Client sends verbs to a sprint server.
type Request ¶
type Request struct {
Verbs [][]string `json:"verbs"`
}
Request is a worker's verbs, in the order to run them.
type Response ¶
type Response struct {
Results []Result `json:"results"`
}
Response is the answers, one a verb, in the request's order.
type Result ¶
type Result struct {
Code int `json:"code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
Result is one verb's answer: nova-sprint's exit code, and what it printed.
type Worker ¶
type Worker struct {
// Send delivers verbs to the server in one request: Client.Do in
// production, the server's own step in a test (no connection).
Send func(ctx context.Context, verbs ...[]string) ([]Result, error)
// Failed shapes what a verb that did not exit 0 printed, for the member's
// log; nil is its stderr, then its stdout.
Failed func(stdout, stderr []byte) []byte
// Budget bounds one verb, its tries together; 0 is Timeout.
Budget time.Duration
// contains filtered or unexported fields
}
Worker runs a worker's sprint verbs on the sprint's server: each verb's arguments are sent and its exit code and what it printed come back, as when the worker ran nova-sprint itself, so a member is the same loop over either. The worker's machine reads and writes nothing of the store.
func (*Worker) Run ¶
Run sends one verb and returns its exit code and output; 2, with why, when the server did not answer. The server's own refusals may exit 2 as well (nova-sprint's refuse() returns 2, and serve passes the code through), so the code alone does not say what became of the write: RunAnswer does.