fanout

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 6 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 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

View Source
const DefaultMax = 16

DefaultMax is used when nothing configures the fan-out.

Variables

This section is empty.

Functions

func Failures

func Failures(results []*transport.Result) []*transport.Result

Failures returns the results that did not succeed.

func Succeeded

func Succeeded(results []*transport.Result) *nodeset.NodeSet

Succeeded returns the node set whose targets succeeded.

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

func GroupByOutput(results []*transport.Result) []Group

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.

Jump to

Keyboard shortcuts

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