clientrunner

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientRunner

type ClientRunner interface {
	OpenSocketCtrl() error
	StartServer(ctx context.Context, sc *clientrpc.ClientControllerRPC, readyCh chan error, doneCh chan error)
	Attach(terminal *api.AttachedTerminal) error
	ID() api.ID
	Close(reason error) error
	Resize(args api.ResizeArgs)
	CreateMetadata() error
	Detach() error
	StartTerminalCmd(terminal *api.AttachedTerminal) error
	Metadata() (*api.ClientDoc, error)
	State() (*api.ClientStatusMode, error)
}

func NewClientRunnerExec

func NewClientRunnerExec(
	ctx context.Context,
	logger *slog.Logger,
	doc *api.ClientDoc,
	evCh chan<- Event,
) ClientRunner

func NewClientRunnerExecWithIO added in v0.8.0

func NewClientRunnerExecWithIO(
	ctx context.Context,
	logger *slog.Logger,
	doc *api.ClientDoc,
	evCh chan<- Event,
	stdin, stdout, stderr *os.File,
) ClientRunner

NewClientRunnerExecWithIO is like NewClientRunnerExec but lets the caller plug in custom stdin/stdout/stderr handles instead of the process's own. A nil handle falls back to the corresponding os.Std*.

type Event

type Event struct {
	ID    api.ID
	Type  EventType
	Bytes int   // for EvData
	Err   error // for EvClosed/EvError
	When  time.Time
}

type EventType

type EventType int
const (
	EvError EventType = iota // abnormal error
	EvCmdExited
	EvDetach
)

type Exec

type Exec struct {
	Mgr *terminalstore.Exec
	// contains filtered or unexported fields
}

func (*Exec) Attach

func (sr *Exec) Attach(terminal *api.AttachedTerminal) error

func (*Exec) Close

func (sr *Exec) Close(_ error) error

func (*Exec) CreateMetadata

func (sr *Exec) CreateMetadata() error

func (*Exec) Detach

func (sr *Exec) Detach() error

func (*Exec) ID

func (sr *Exec) ID() api.ID

func (*Exec) Metadata added in v0.8.0

func (sr *Exec) Metadata() (*api.ClientDoc, error)

Metadata returns a snapshot of the runner's ClientDoc. The returned pointer is a deep copy — callers may freely mutate it without racing the runner's own metadata writes.

func (*Exec) OpenSocketCtrl

func (sr *Exec) OpenSocketCtrl() error

func (*Exec) Resize

func (sr *Exec) Resize(_ api.ResizeArgs)

func (*Exec) StartServer

func (sr *Exec) StartServer(
	ctx context.Context,
	sc *clientrpc.ClientControllerRPC,
	readyCh chan error,
	doneCh chan error,
)

func (*Exec) StartTerminalCmd

func (sr *Exec) StartTerminalCmd(terminal *api.AttachedTerminal) error

func (*Exec) State added in v0.8.0

func (sr *Exec) State() (*api.ClientStatusMode, error)

State returns the current lifecycle state of the client.

func (*Exec) WaitClose

func (sr *Exec) WaitClose(_ error) error

type Test

type Test struct {
	Ctx    context.Context
	Logger *slog.Logger
	// Last-call trackers
	LastListener   net.Listener
	LastController *clientrpc.ClientControllerRPC
	LastCtx        context.Context
	LastReason     error
	LastResize     api.ResizeArgs

	// Stub functions
	OpenSocketCtrlFunc func() error
	StartServerFunc    func(
		ctx context.Context,
		sc *clientrpc.ClientControllerRPC,
		readyCh chan error,
		doneCh chan error,
	)
	IDFunc               func() api.ID
	CloseFunc            func(reason error) error
	ResizeFunc           func(args api.ResizeArgs)
	AttachFunc           func(terminal *api.AttachedTerminal) error
	CreateMetadataFunc   func() error
	DetachFunc           func() error
	StartTerminalCmdFunc func(terminal *api.AttachedTerminal) error
	MetadataFunc         func() (*api.ClientDoc, error)
	StateFunc            func() (*api.ClientStatusMode, error)
}

Test is a test double for ClientRunner It allows overriding behavior with function fields and capturing arguments for assertions in unit tests.

func NewClientRunnerTest

func NewClientRunnerTest(ctx context.Context, _ *api.ClientDoc) *Test

NewClientRunnerTest returns a new ClientRunnerTest instance.

func (*Test) Attach

func (t *Test) Attach(terminal *api.AttachedTerminal) error

func (*Test) Close

func (t *Test) Close(reason error) error

func (*Test) CreateMetadata

func (t *Test) CreateMetadata() error

func (*Test) Detach

func (t *Test) Detach() error

func (*Test) ID

func (t *Test) ID() api.ID

func (*Test) Metadata added in v0.8.0

func (t *Test) Metadata() (*api.ClientDoc, error)

func (*Test) OpenSocketCtrl

func (t *Test) OpenSocketCtrl() error

func (*Test) Resize

func (t *Test) Resize(args api.ResizeArgs)

func (*Test) StartServer

func (t *Test) StartServer(
	ctx context.Context,
	sc *clientrpc.ClientControllerRPC,
	readyCh chan error,
	doneCh chan error,
)

func (*Test) StartTerminalCmd

func (t *Test) StartTerminalCmd(terminal *api.AttachedTerminal) error

func (*Test) State added in v0.8.0

func (t *Test) State() (*api.ClientStatusMode, error)

type UIMode

type UIMode int
const (
	UIBash UIMode = iota
	UIClient
	UIExitShell // Saved lastState restore
)

Jump to

Keyboard shortcuts

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