dispatch

package
v0.0.0-...-c6bcdba Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: GPL-3.0 Imports: 7 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 {
	// contains filtered or unexported fields
}

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.

func (*Command) Cmd

func (c *Command) Cmd() string

func (*Command) Env

func (c *Command) Env() map[string]string

func (*Command) Stderr

func (c *Command) Stderr() io.Writer

func (*Command) Stdout

func (c *Command) Stdout() io.Writer

func (*Command) Timeout

func (c *Command) Timeout() time.Duration

type Node

type Node struct {
	Name string
	// Kubename is the name of the node in the Kubernetes cluster.
	// Must always follow the format `master` for the master node, and
	// `worker-<n>` for worker nodes (1-indexed).
	Kubename 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