dispatch

package
v0.0.0-...-28f0728 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrefixWriter

func NewPrefixWriter(prefix string, writer io.Writer) io.Writer

func WithEnv

func WithEnv(env map[string]string) optionLoader

func WithOsPipe

func WithOsPipe() optionLoader

WithOsPipe sets the stdout and stderr of the command to `os.Stdout` and `os.Stderr`.

func WithPrefixWriter

func WithPrefixWriter(node Node) optionLoader

WithPrefixWriter sets the prefix writer for the command. Must be used after WithStdout or WithStderr.

func WithStderr

func WithStderr(w io.Writer) optionLoader

WithStderr sets the stderr writer for the command. If `nil`, it defaults to `os.Stderr`.

func WithStdout

func WithStdout(w io.Writer) optionLoader

WithStdout sets the stdout writer for the command. If `nil`, it defaults to `os.Stdout`.

func WithTimeout

func WithTimeout(timeout time.Duration) optionLoader

WithTimeout sets the timeout for the command.

Types

type ClusterDispatcher

type ClusterDispatcher interface {
	// GetNodes returns all nodes in the cluster.
	GetNodes() []Node
	// GetMasterNode returns the master node in the cluster.
	GetMasterNode() Node
	// GetWorkerNodes returns all worker nodes in the cluster.
	GetWorkerNodes() []Node
	// Ready checks if the cluster is ready to accept commands.
	Ready() bool
	// SendCommands sends commands to a node in the cluster.
	SendCommands(node Node, cmds ...Command) error
	// SendCommandsContext sends commands to a node in the cluster with a custom context.
	SendCommandsContext(ctx context.Context, node Node, cmds ...Command) error
	// SendFile sends a file to a node in the cluster.
	SendFile(node Node, src, dst string) error
	// DownloadProject sets up the log-console project into the given node. If the source begins with
	// local://, it'll mount the local directory into the node. For all other sources, it'll git
	// clone the URL.
	DownloadProject(node Node, source string) error
	// Cleanup disposes of any held resources.
	Cleanup() error
}

type Command

type Command struct {
	Cmd     string
	Env     map[string]string
	Stdout  io.Writer
	Stderr  io.Writer
	Timeout time.Duration
}

func NewCommand

func NewCommand(cmdStr string, opts ...optionLoader) Command

NewCommand creates a command object from a command string with provided options.

func NewCommands

func NewCommands(cmdStrs []string, opts ...optionLoader) []Command

NewCommands creates a list of command objects from the provided command strings, and options.

type Node

type Node struct {
	Name   string
	Remote UserQualifiedHostname
}

type PrefixWriter

type PrefixWriter struct {
	// contains filtered or unexported fields
}

func (*PrefixWriter) Write

func (p *PrefixWriter) Write(b []byte) (n int, err error)

Write writes the prefix before the actual bytes to the underlying writer.

type UserQualifiedHostname

type UserQualifiedHostname struct {
	User string
	FQDN string
}

func (*UserQualifiedHostname) ParseString

func (UserQualifiedHostname) String

func (r UserQualifiedHostname) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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