execution

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package execution provides an abstraction for a single execution of a command with the context of daemonservice.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrShuttingDown is returned once an execution has started shutting down and
	// is no longer accepting messages.
	ErrShuttingDown = errors.New("shutting down")
)

Functions

This section is empty.

Types

type Execution

type Execution struct {
	StartTime time.Time
	// contains filtered or unexported fields
}

An Execution represents a specific execution of a daemonservice.

func New

func New(ctx context.Context, daemonServiceName string, cfg *dspb.Config, sc service.Context) (*Execution, error)

New creates and starts an execution of the command described in cfg. Messages received from the resulting process are passed to sc, as are StdOutput and ResourceUsage messages.

The context needs to be valid for the lifetime of the whole process execution!

func (*Execution) LastActive

func (e *Execution) LastActive() time.Time

LastActive returns the last time that a message was sent or received, to the nearest second.

func (*Execution) SendMsg

func (e *Execution) SendMsg(ctx context.Context, m *fspb.Message) error

SendMsg sends m to the execution.

It returns nil on success, ErrShuttingDown if the output channel was already closed, and context.Cause(ctx) if ctx was canceled.

func (*Execution) Shutdown

func (e *Execution) Shutdown()

Shutdown shuts down this execution.

func (*Execution) Wait

func (e *Execution) Wait() error

Wait waits for all aspects of this execution to finish. This should happen soon after shutdown is called. Wait must be called to free up resources and to reap the child process.

Jump to

Keyboard shortcuts

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