supervisorrunner

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event added in v0.1.4

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

type EventType added in v0.1.4

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

type Exec added in v0.1.4

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

func (*Exec) Attach added in v0.1.4

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

func (*Exec) Close added in v0.1.4

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

func (*Exec) CreateMetadata added in v0.1.4

func (sr *Exec) CreateMetadata() error

func (*Exec) Detach added in v0.1.4

func (sr *Exec) Detach() error

func (*Exec) ID added in v0.1.4

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

func (*Exec) OpenSocketCtrl added in v0.1.4

func (sr *Exec) OpenSocketCtrl() error

func (*Exec) Resize added in v0.1.4

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

func (*Exec) StartServer added in v0.1.4

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

func (*Exec) StartTerminalCmd added in v0.3.0

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

func (*Exec) WaitClose added in v0.1.4

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

type SupervisorRunner

type SupervisorRunner interface {
	OpenSocketCtrl() error
	StartServer(ctx context.Context, sc *supervisorrpc.SupervisorControllerRPC, readyCh chan error, doneCh chan error)
	Attach(terminal *api.SupervisedTerminal) error
	ID() api.ID
	Close(reason error) error
	Resize(args api.ResizeArgs)
	CreateMetadata() error
	Detach() error
	StartTerminalCmd(terminal *api.SupervisedTerminal) error
}

func NewSupervisorRunnerExec

func NewSupervisorRunnerExec(
	ctx context.Context,
	logger *slog.Logger,
	doc *api.SupervisorDoc,
	evCh chan<- Event,
) SupervisorRunner

type Test added in v0.1.4

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

	// Stub functions
	OpenSocketCtrlFunc func() error
	StartServerFunc    func(
		ctx context.Context,
		sc *supervisorrpc.SupervisorControllerRPC,
		readyCh chan error,
		doneCh chan error,
	)
	IDFunc               func() api.ID
	CloseFunc            func(reason error) error
	ResizeFunc           func(args api.ResizeArgs)
	AttachFunc           func(terminal *api.SupervisedTerminal) error
	CreateMetadataFunc   func() error
	DetachFunc           func() error
	StartTerminalCmdFunc func(terminal *api.SupervisedTerminal) error
}

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

func NewSupervisorRunnerTest

func NewSupervisorRunnerTest(ctx context.Context, _ *api.SupervisorDoc) *Test

NewSupervisorRunnerTest returns a new SupervisorRunnerTest instance.

func (*Test) Attach added in v0.1.4

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

func (*Test) Close added in v0.1.4

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

func (*Test) CreateMetadata added in v0.1.4

func (t *Test) CreateMetadata() error

func (*Test) Detach added in v0.1.4

func (t *Test) Detach() error

func (*Test) ID added in v0.1.4

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

func (*Test) OpenSocketCtrl added in v0.1.4

func (t *Test) OpenSocketCtrl() error

func (*Test) Resize added in v0.1.4

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

func (*Test) StartServer added in v0.1.4

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

func (*Test) StartTerminalCmd added in v0.3.0

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

type UIMode

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