execx

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOutputLimitExceeded = errors.New("execx: output limit exceeded")
	ErrProcessNotRunning   = errors.New("execx: process is not running")
	ErrProcessRunning      = errors.New("execx: process is already running")
)

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Decode(data []byte) (string, error)
}

type DecoderFunc

type DecoderFunc func(data []byte) (string, error)

func (DecoderFunc) Decode

func (f DecoderFunc) Decode(data []byte) (string, error)

type Event

type Event struct {
	Stream    Stream
	Data      []byte
	Text      string
	Time      time.Time
	DecodeErr error
}

type ExitError

type ExitError struct {
	Result Result
	Err    error
}

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type MultiSink

type MultiSink []Sink

func (MultiSink) WriteCommandEvent

func (s MultiSink) WriteCommandEvent(ctx context.Context, event Event) error

type Option

type Option func(*config)

func WithCleanEnv

func WithCleanEnv() Option

func WithDecodeFunc

func WithDecodeFunc(fn func([]byte) (string, error)) Option

func WithDecoder

func WithDecoder(decoder Decoder) Option

func WithDir

func WithDir(dir string) Option

func WithEnv

func WithEnv(env []string) Option

func WithInputString

func WithInputString(s string) Option

func WithKillProcessGroup

func WithKillProcessGroup() Option

func WithLineBufferSize

func WithLineBufferSize(n int) Option

func WithMergeStderr

func WithMergeStderr() Option

func WithOutputLimit

func WithOutputLimit(n int64) Option

func WithRingBuffer

func WithRingBuffer(n int) Option

func WithShell

func WithShell(name string, args ...string) Option

func WithSink

func WithSink(sink Sink) Option

func WithSplitMode

func WithSplitMode(mode SplitMode) Option

func WithStdin

func WithStdin(r io.Reader) Option

func WithStopTimeout

func WithStopTimeout(d time.Duration) Option

func WithStrictDecode

func WithStrictDecode() Option

func WithWaitDelay

func WithWaitDelay(d time.Duration) Option

type OutputResult

type OutputResult struct {
	Result
	Stdout   []byte
	Stderr   []byte
	Combined []byte
}

func RunOutput

func RunOutput(ctx context.Context, name string, args []string, opts ...Option) (OutputResult, error)

func RunShellOutput

func RunShellOutput(ctx context.Context, script string, opts ...Option) (OutputResult, error)

type Process

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

func Start

func Start(ctx context.Context, name string, args []string, opts ...Option) (*Process, error)

func StartShell

func StartShell(ctx context.Context, script string, opts ...Option) (*Process, error)

func (*Process) Done

func (p *Process) Done() <-chan Result

func (*Process) Kill

func (p *Process) Kill() error

func (*Process) PID

func (p *Process) PID() int

func (*Process) RecentEvents

func (p *Process) RecentEvents() []Event

func (*Process) Running

func (p *Process) Running() bool

func (*Process) Signal

func (p *Process) Signal(sig os.Signal) error

func (*Process) Stop

func (p *Process) Stop(ctx context.Context) error

func (*Process) Wait

func (p *Process) Wait() (Result, error)

type Result

type Result struct {
	Command    string
	Args       []string
	Dir        string
	PID        int
	ExitCode   int
	StartedAt  time.Time
	FinishedAt time.Time
}

func Run

func Run(ctx context.Context, name string, args []string, opts ...Option) (Result, error)

func RunShell

func RunShell(ctx context.Context, script string, opts ...Option) (Result, error)

func RunShellStream

func RunShellStream(ctx context.Context, script string, sink Sink, opts ...Option) (Result, error)

func RunStream

func RunStream(ctx context.Context, name string, args []string, sink Sink, opts ...Option) (Result, error)

type RingSink

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

func NewRingSink

func NewRingSink(limit int) *RingSink

func (*RingSink) Events

func (s *RingSink) Events() []Event

func (*RingSink) WriteCommandEvent

func (s *RingSink) WriteCommandEvent(ctx context.Context, event Event) error

type Sink

type Sink interface {
	WriteCommandEvent(ctx context.Context, event Event) error
}

type SinkFunc

type SinkFunc func(ctx context.Context, event Event) error

func (SinkFunc) WriteCommandEvent

func (f SinkFunc) WriteCommandEvent(ctx context.Context, event Event) error

type SplitMode

type SplitMode int
const (
	SplitLine SplitMode = iota
	SplitCRLF
	SplitChunk
)

type Stream

type Stream string
const (
	StreamStdout Stream = "stdout"
	StreamStderr Stream = "stderr"
)

type WriterSink

type WriterSink struct {
	Writer io.Writer
}

func NewWriterSink

func NewWriterSink(w io.Writer) WriterSink

func (WriterSink) WriteCommandEvent

func (s WriterSink) WriteCommandEvent(ctx context.Context, event Event) error

Jump to

Keyboard shortcuts

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