commands

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 11 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 commands serves the executor CommandService over a Runner.

Index

Constants

This section is empty.

Variables

View Source
var ErrStartUnknown = errors.New("command start outcome unknown")

ErrStartUnknown reports a failed start that may have run the command.

Functions

This section is empty.

Types

type Exit

type Exit struct {
	Code int
	// Confirmed reports that no process the command started is left running.
	Confirmed bool
}

Exit is how a command ended.

type Option

type Option func(*Server) error

Option configures a Server.

func WithMaxCommandBytes

func WithMaxCommandBytes(n int) Option

WithMaxCommandBytes bounds the length of a command.

func WithMaxOutputBytes

func WithMaxOutputBytes(n int) Option

WithMaxOutputBytes bounds the combined stdout and stderr of a command.

func WithMaxTimeout

func WithMaxTimeout(d time.Duration) Option

WithMaxTimeout caps the timeout of every command.

type Process

type Process interface {
	// Wait returns after the command ends and its output has been written.
	Wait() Exit
}

Process is a started command.

type Runner

type Runner interface {
	// Start returns once the command runs, or an error if it never ran, or
	// one wrapping ErrStartUnknown if it may have.
	// Ending ctx kills the command and every process it started.
	Start(ctx context.Context, command string, stdout, stderr io.Writer) (Process, error)
}

Runner starts commands for the service.

type Server

type Server struct {
	executorv1.UnimplementedCommandServiceServer
	// contains filtered or unexported fields
}

Server implements executorv1.CommandServiceServer.

func New

func New(runner Runner, opts ...Option) (*Server, error)

New returns a server that runs commands with runner.

func (*Server) RunCommand

RunCommand runs one command per stream.

Jump to

Keyboard shortcuts

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