executor

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package executor provides functionality for running OS commands with streaming output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OSCommandExecutor

type OSCommandExecutor struct {
	SmartDrainThreshold int64
	DefaultTimeout      time.Duration
	// contains filtered or unexported fields
}

OSCommandExecutor implements the command execution service using the OS shell.

func NewOSCommandExecutor

func NewOSCommandExecutor(fs fileSystem) *OSCommandExecutor

NewOSCommandExecutor creates a new OSCommandExecutor with the provided filesystem.

func (*OSCommandExecutor) Run

func (f *OSCommandExecutor) Run(ctx context.Context, command string, dir string, enableLogging bool) (*Result, error)

Run executes a command and waits for its completion.

func (*OSCommandExecutor) RunStreaming

func (f *OSCommandExecutor) RunStreaming(ctx context.Context, command string, dir string, enableLogging bool) (sc *StreamingCmd, err error)

RunStreaming starts a command and returns a StreamingCmd for real-time output.

type Result

type Result struct {
	Stdout    string
	LogPath   string
	ExitCode  int
	Truncated bool
}

Result represents the outcome of a command execution.

type StreamingCmd

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

StreamingCmd represents a running command with real-time output streaming.

func NewStreamingCmd

func NewStreamingCmd(id string, output io.Reader, wait func() (*Result, error), logPath string) *StreamingCmd

NewStreamingCmd creates a new StreamingCmd instance.

func (*StreamingCmd) DisableAutoCleanup

func (s *StreamingCmd) DisableAutoCleanup()

DisableAutoCleanup prevents the command from deleting the log file if it is small.

func (*StreamingCmd) ID

func (s *StreamingCmd) ID() string

ID returns the unique identifier for the command.

func (*StreamingCmd) LastActivityAt

func (s *StreamingCmd) LastActivityAt() time.Time

LastActivityAt returns the time of the most recent output from the command.

func (*StreamingCmd) LogPath

func (s *StreamingCmd) LogPath() string

LogPath returns the path to the file where output is being logged.

func (*StreamingCmd) Output

func (s *StreamingCmd) Output() io.Reader

Output returns a reader for the command's streaming output.

func (*StreamingCmd) UpdateActivity

func (s *StreamingCmd) UpdateActivity()

UpdateActivity updates the last activity timestamp to the current time.

func (*StreamingCmd) Wait

func (s *StreamingCmd) Wait() (*Result, error)

Wait blocks until the command completes and returns the result.

Jump to

Keyboard shortcuts

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