executor

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfigured = errors.New("executor is not configured")

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// Args returns the command and the arguments used to create the process.
	Args() []string
	// SetEnv sets the process environment.
	SetEnv([]string)
	// Env returns the process environment.
	Env() []string
	// SetDir sets the process working directory.
	SetDir(string)
	// Dir returns the process working directory.
	Dir() string
	// SetStdin sets the process standard input.
	SetStdin(io.Reader)
	// SetStdout sets the process standard output.
	SetStdout(io.Writer)
	// Stdout returns the process standard output.
	Stdout() io.Writer
	// SetStderr sets the process standard error.
	SetStderr(io.Writer)
	// Stderr returns the process standard error.
	Stderr() io.Writer
	// Start begins execution of the process.
	Start() error
	// Wait waits for the process to complete.
	Wait() error
	// Signal sends a signal to a running process.
	Signal(syscall.Signal) error
	// PID returns the local process ID of the process if it is running or
	// complete. This is not guaranteed to return a valid value for remote
	// executors and will return -1 if it could not be retrieved.
	PID() int
	// ExitCode returns the exit code of a completed process. This will return a
	// non-negative value if it successfully retrieved the exit code. Callers
	// must call Wait before retrieving the exit code.
	ExitCode() int
	// Success returns whether or not the completed process ran successfully.
	// Callers must call Wait before checking for success.
	Success() bool
	// SignalInfo returns information about signals the process has received.
	SignalInfo() (sig syscall.Signal, signaled bool)
	// Close cleans up the executor's resources. Users should not assume the
	// information from the Executor will be accurate after it has been closed.
	Close() error
}

Executor is an interface by which Jasper processes can manipulate and introspect on processes. Implementations are not guaranteed to be thread-safe.

func MakeLocal

func MakeLocal(cmd *exec.Cmd) Executor

MakeLocal wraps an existing local process.

func NewLocal

func NewLocal(ctx context.Context, args []string) (Executor, error)

NewLocal returns an Executor that creates processes locally.

type Status

type Status int

Status represents the current state of a process execution

const (
	// Unknown means the process is in an unknown or invalid state.
	Unknown Status = iota
	// Unstarted means that the Executor has not yet started running the
	// process.
	Unstarted Status = iota
	// Running means that the Executor has started running the process.
	Running Status = iota
	// Exited means the Executor has finished running the process.
	Exited Status = iota
	// Closed means the Executor has cleaned up its resources and further
	// requests cannot be made.
	Closed Status = iota
)

func (Status) After

func (s Status) After(other Status) bool

func (Status) AfterInclusive

func (s Status) AfterInclusive(other Status) bool

func (Status) Before

func (s Status) Before(other Status) bool

func (Status) BeforeInclusive

func (s Status) BeforeInclusive(other Status) bool

func (Status) Between

func (s Status) Between(lower Status, upper Status) bool

func (Status) BetweenInclusive

func (s Status) BetweenInclusive(lower Status, upper Status) bool

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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