Documentation
¶
Index ¶
- func IsHeartbeatEvent(event StreamEvent) bool
- func IsPTYOutputEvent(event StreamEvent) bool
- func IsPipeOutputEvent(event StreamEvent) bool
- func IsProcessEndEvent(event StreamEvent) bool
- func IsProcessErrorEvent(event StreamEvent) bool
- func IsProcessLifecycleEvent(event StreamEvent) bool
- func IsProcessStartEvent(event StreamEvent) bool
- func IsTerminalResizeEvent(event StreamEvent) bool
- func ToAscicastV3(events iter.Seq2[Event, error], metadata AscicastV3Metadata) iter.Seq2[AscicastV3Line, error]
- func WriteAscicastV3(events iter.Seq2[Event, error], metadata AscicastV3Metadata, ...) error
- type AscicastV3Event
- type AscicastV3Header
- type AscicastV3Line
- type AscicastV3Metadata
- type BufferWriter
- type Cancellor
- type Event
- type EventType
- type HeartbeatEvent
- type LocalCancellor
- type PTYOutputData
- type PTYProcess
- type PTYStats
- func (s *PTYStats) GetSnapshot() PTYStatsSnapshot
- func (s *PTYStats) RecordError(ctx context.Context, eventType string)
- func (s *PTYStats) RecordEvent(ctx context.Context, eventType string)
- func (s *PTYStats) RecordOutput(ctx context.Context, dataSize int64)
- func (s *PTYStats) SetExitCode(code int)
- func (s *PTYStats) Start(ctx context.Context)
- func (s *PTYStats) Stop(ctx context.Context)
- type PTYStatsSnapshot
- type PipeOutputData
- type PipeProcess
- type PipeProcessFailedError
- type PipeProcessKilledError
- type ProcessEnd
- type ProcessError
- type ProcessInfo
- type ProcessOption
- func WithCancellor(cancellor Cancellor) ProcessOption
- func WithEnv(env []string) ProcessOption
- func WithEnvMap(envMap map[string]string) ProcessOption
- func WithEnvVar(key, value string) ProcessOption
- func WithFlushInterval(interval time.Duration) ProcessOption
- func WithMaxBufferSize(size int) ProcessOption
- func WithMeter(meter any) ProcessOption
- func WithMetricsInterval(interval time.Duration) ProcessOption
- func WithPTYSize(size pty.Winsize) ProcessOption
- type ProcessStart
- type ProcessStartError
- type StreamEvent
- type StreamType
- type TermInfo
- type TerminalResizeEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsHeartbeatEvent ¶
func IsHeartbeatEvent(event StreamEvent) bool
func IsPTYOutputEvent ¶
func IsPTYOutputEvent(event StreamEvent) bool
func IsPipeOutputEvent ¶
func IsPipeOutputEvent(event StreamEvent) bool
func IsProcessEndEvent ¶
func IsProcessEndEvent(event StreamEvent) bool
func IsProcessErrorEvent ¶
func IsProcessErrorEvent(event StreamEvent) bool
func IsProcessLifecycleEvent ¶
func IsProcessLifecycleEvent(event StreamEvent) bool
func IsProcessStartEvent ¶
func IsProcessStartEvent(event StreamEvent) bool
func IsTerminalResizeEvent ¶
func IsTerminalResizeEvent(event StreamEvent) bool
func ToAscicastV3 ¶
func ToAscicastV3(events iter.Seq2[Event, error], metadata AscicastV3Metadata) iter.Seq2[AscicastV3Line, error]
ToAscicastV3 transforms a stream of console-stream events into asciicast v3 format
func WriteAscicastV3 ¶
func WriteAscicastV3(events iter.Seq2[Event, error], metadata AscicastV3Metadata, writeFunc func([]byte) error) error
WriteAscicastV3 is a convenience function to write asciicast v3 to any writer
Types ¶
type AscicastV3Event ¶
type AscicastV3Event [3]any
AscicastV3Event represents an event line in asciicast v3 format: [interval, code, data]
func NewExitEvent ¶
func NewExitEvent(interval float64, exitCode int) AscicastV3Event
NewExitEvent creates an asciicast exit event
func NewOutputEvent ¶
func NewOutputEvent(interval float64, data string) AscicastV3Event
NewOutputEvent creates an asciicast output event
func NewResizeEvent ¶
func NewResizeEvent(interval float64, cols, rows uint16) AscicastV3Event
NewResizeEvent creates an asciicast resize event
func (AscicastV3Event) MarshalJSON ¶
func (e AscicastV3Event) MarshalJSON() ([]byte, error)
MarshalJSON implements AscicastV3Line interface for events
type AscicastV3Header ¶
type AscicastV3Header struct {
Version int `json:"version"`
AscicastV3Metadata
}
AscicastV3Header represents the first line of an asciicast v3 file
func (AscicastV3Header) MarshalJSON ¶
func (h AscicastV3Header) MarshalJSON() ([]byte, error)
MarshalJSON implements AscicastV3Line interface for headers
type AscicastV3Line ¶
AscicastV3Line represents either a header or event line in asciicast v3 format
type AscicastV3Metadata ¶
type AscicastV3Metadata struct {
Term TermInfo `json:"term"`
Timestamp *int64 `json:"timestamp,omitempty"`
Command string `json:"command,omitempty"`
Title string `json:"title,omitempty"`
Env map[string]string `json:"env,omitempty"`
Tags []string `json:"tags,omitempty"`
}
AscicastV3Metadata contains the metadata for the asciicast header
type BufferWriter ¶ added in v0.2.0
type BufferWriter struct {
// contains filtered or unexported fields
}
BufferWriter wraps buffer operations and implements io.WriteCloser This can be used by both PipeProcess and PTYProcess for consistent buffer management
func NewBufferWriter ¶ added in v0.2.0
func NewBufferWriter(flushChan chan<- struct{}, maxBufferSize int) *BufferWriter
func (*BufferWriter) Close ¶ added in v0.2.0
func (w *BufferWriter) Close() error
func (*BufferWriter) FlushAndClear ¶ added in v0.2.0
func (w *BufferWriter) FlushAndClear() []byte
FlushAndClear returns the current buffer contents and clears it
func (*BufferWriter) Len ¶ added in v0.2.0
func (w *BufferWriter) Len() int
Len returns the current buffer length (thread-safe)
type Event ¶
type Event struct {
Timestamp time.Time
Event StreamEvent
}
type HeartbeatEvent ¶
HeartbeatEvent represents a keep-alive signal when no output is generated
func (*HeartbeatEvent) String ¶
func (h *HeartbeatEvent) String() string
func (*HeartbeatEvent) Type ¶
func (h *HeartbeatEvent) Type() EventType
type LocalCancellor ¶
type LocalCancellor struct {
// contains filtered or unexported fields
}
LocalCancellor implements process cancellation for local processes
func NewLocalCancellor ¶
func NewLocalCancellor(terminateTimeout time.Duration) *LocalCancellor
type PTYOutputData ¶
type PTYOutputData struct {
Data string
}
PTYOutputData represents terminal output from a PTY process with ANSI sequences preserved
func (*PTYOutputData) String ¶
func (p *PTYOutputData) String() string
func (*PTYOutputData) Type ¶
func (p *PTYOutputData) Type() EventType
type PTYProcess ¶
type PTYProcess struct {
// contains filtered or unexported fields
}
PTYProcess represents a process running in a pseudo-terminal
func NewPTYProcess ¶
func NewPTYProcess(cmd string, args []string, opts ...ProcessOption) *PTYProcess
NewPTYProcess creates a new PTY process with functional options
func (*PTYProcess) ExecuteAndStream ¶
ExecuteAndStream starts a PTY process and returns an iterator over Event objects
func (*PTYProcess) GetStats ¶ added in v0.2.1
func (p *PTYProcess) GetStats() PTYStatsSnapshot
GetStats returns a copy of the current PTY process statistics
type PTYStats ¶ added in v0.2.1
type PTYStats struct {
// contains filtered or unexported fields
}
PTYStats manages comprehensive metrics during PTY process execution
func NewPTYStats ¶ added in v0.2.1
func NewPTYStats(meter metric.Meter, interval time.Duration, processInfo ProcessInfo) (*PTYStats, error)
NewPTYStats creates a new PTYStats instance with OpenTelemetry metrics
func (*PTYStats) GetSnapshot ¶ added in v0.2.1
func (s *PTYStats) GetSnapshot() PTYStatsSnapshot
GetSnapshot returns a thread-safe snapshot of the current statistics
func (*PTYStats) RecordError ¶ added in v0.2.1
RecordError increments the error count
func (*PTYStats) RecordEvent ¶ added in v0.2.1
RecordEvent records a general event
func (*PTYStats) RecordOutput ¶ added in v0.2.1
RecordOutput records output data and metrics
func (*PTYStats) SetExitCode ¶ added in v0.2.1
SetExitCode sets the process exit code
type PTYStatsSnapshot ¶ added in v0.2.1
type PTYStatsSnapshot struct {
// Basic execution stats
StartTime time.Time
EventCount int
ErrorCount int
ExitCode *int
Duration time.Duration
// contains filtered or unexported fields
}
PTYStatsSnapshot represents a point-in-time view of PTY process statistics
type PipeOutputData ¶
type PipeOutputData struct {
Data []byte
Stream StreamType
}
PipeOutputData represents stdout/stderr data from the process
func (*PipeOutputData) String ¶
func (o *PipeOutputData) String() string
func (*PipeOutputData) Type ¶
func (o *PipeOutputData) Type() EventType
type PipeProcess ¶
type PipeProcess struct {
// contains filtered or unexported fields
}
func NewPipeProcess ¶
func NewPipeProcess(cmd string, args []string, opts ...ProcessOption) *PipeProcess
func (*PipeProcess) ExecuteAndStream ¶
ExecuteAndStream starts a process and returns an iterator over Event objects
type PipeProcessFailedError ¶
func (PipeProcessFailedError) Error ¶
func (e PipeProcessFailedError) Error() string
type PipeProcessKilledError ¶
func (PipeProcessKilledError) Error ¶
func (e PipeProcessKilledError) Error() string
type ProcessEnd ¶
ProcessEnd represents the completion of process execution
func (*ProcessEnd) String ¶
func (p *ProcessEnd) String() string
func (*ProcessEnd) Type ¶
func (p *ProcessEnd) Type() EventType
type ProcessError ¶
ProcessError represents an error during process execution
func (*ProcessError) String ¶
func (p *ProcessError) String() string
func (*ProcessError) Type ¶
func (p *ProcessError) Type() EventType
type ProcessInfo ¶ added in v0.2.1
ProcessInfo contains process information for metrics attributes
type ProcessOption ¶
type ProcessOption func(*processConfig)
ProcessOption represents a functional option for configuring processes
func WithCancellor ¶
func WithCancellor(cancellor Cancellor) ProcessOption
WithCancellor sets a custom cancellor for the process
func WithEnv ¶
func WithEnv(env []string) ProcessOption
WithEnv sets environment variables as a slice of "KEY=value" strings
func WithEnvMap ¶
func WithEnvMap(envMap map[string]string) ProcessOption
WithEnvMap sets environment variables from a map for convenience
func WithEnvVar ¶
func WithEnvVar(key, value string) ProcessOption
WithEnvVar sets a single environment variable
func WithFlushInterval ¶
func WithFlushInterval(interval time.Duration) ProcessOption
WithFlushInterval sets how often to flush output buffers
func WithMaxBufferSize ¶
func WithMaxBufferSize(size int) ProcessOption
WithMaxBufferSize sets the maximum buffer size before forcing a flush
func WithMeter ¶ added in v0.2.1
func WithMeter(meter any) ProcessOption
WithMeter sets an OpenTelemetry meter for metrics collection
func WithMetricsInterval ¶ added in v0.2.1
func WithMetricsInterval(interval time.Duration) ProcessOption
WithMetricsInterval sets how often to aggregate metrics into buckets
func WithPTYSize ¶
func WithPTYSize(size pty.Winsize) ProcessOption
WithPTYSize sets a custom terminal size for the PTY process
type ProcessStart ¶
ProcessStart represents the beginning of process execution
func (*ProcessStart) String ¶
func (p *ProcessStart) String() string
func (*ProcessStart) Type ¶
func (p *ProcessStart) Type() EventType
type ProcessStartError ¶
Error types for different process failure scenarios
func (ProcessStartError) Error ¶
func (e ProcessStartError) Error() string
type StreamEvent ¶
StreamEvent represents different types of events that can occur during process execution
type StreamType ¶
type StreamType int
const ( Stdout StreamType = iota Stderr )
func (StreamType) String ¶
func (s StreamType) String() string
type TerminalResizeEvent ¶
type TerminalResizeEvent struct {
Rows uint16
Cols uint16
X uint16 // Width in pixels
Y uint16 // Height in pixels
}
TerminalResizeEvent represents a terminal window size change
func (*TerminalResizeEvent) String ¶
func (t *TerminalResizeEvent) String() string
func (*TerminalResizeEvent) Type ¶
func (t *TerminalResizeEvent) Type() EventType
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
runner
command
Package main provides a pretty slog handler for human-readable colored terminal output.
|
Package main provides a pretty slog handler for human-readable colored terminal output. |
|
tester
command
|
|
|
example
|
|
|
asciicast
command
|
|
|
buffering
command
|
|
|
burst
command
|
|
|
logging
command
|
|
|
pty
command
|
|
|
simple
command
|
|
|
stream
command
|