Documentation
¶
Overview ¶
Package fanout runs one request on many targets at once.
The degree of parallelism is bounded and conservative by default: a connection through a tunnel or a jump host is far more fragile than a local one, and a wide fan-out is what makes sshd refuse connections under its MaxStartups limit.
Index ¶
Constants ¶
const DefaultMax = 16
DefaultMax is used when nothing configures the fan-out.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Executor ¶
type Executor struct {
// Runner performs one request; a Recorder stands in for a dry run.
Runner transport.Runner
// Max is how many targets are worked on at once.
Max int
// OnResult is called as each target finishes, in completion order, for
// progress output. It must be safe to call from several goroutines.
OnResult func(*transport.Result)
}
Executor runs requests on many targets.
func (*Executor) Run ¶
func (e *Executor) Run(ctx context.Context, targets []transport.Target, req transport.Request) []*transport.Result
Run executes the same request on every target.
func (*Executor) RunEach ¶
func (e *Executor) RunEach(ctx context.Context, targets []transport.Target, build func(transport.Target) transport.Request) []*transport.Result
RunEach executes a request built per target, which is how a command sends each node its own arguments.
Results come back in the order the targets were given, whatever order they finished in, so output is reproducible. A target that fails does not stop the others: the point of a fan-out is to learn about every node.
type Group ¶
type Group struct {
// Nodes are the targets that produced this output.
Nodes *nodeset.NodeSet `json:"nodes" yaml:"nodes"`
// Output is the standard output they shared.
Output string `json:"output" yaml:"output"`
// ExitCode is the status they shared.
ExitCode int `json:"exitCode" yaml:"exitCode"`
}
Group is a set of targets that produced identical output.
func GroupByOutput ¶
GroupByOutput collects targets that answered the same thing, which turns the output of a thousand nodes into the handful of answers worth reading.
Groups come back largest first, and equally sized groups in node set order, so two runs of the same command print the same thing.