blockcontroller

package
v0.11.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BlockController_Shell   = "shell"
	BlockController_Cmd     = "cmd"
	BlockController_Tsunami = "tsunami"
)
View Source
const (
	Status_Running = "running"
	Status_Done    = "done"
	Status_Init    = "init"
)
View Source
const (
	DefaultTermMaxFileSize = 256 * 1024
	DefaultHtmlMaxFileSize = 256 * 1024
	MaxInitScriptSize      = 50 * 1024
)
View Source
const (
	ConnType_Local = "local"
	ConnType_Wsl   = "wsl"
	ConnType_Ssh   = "ssh"
)
View Source
const DefaultGracefulKillWait = 400 * time.Millisecond
View Source
const DefaultTimeout = 2 * time.Second

Variables

This section is empty.

Functions

func CheckConnStatus

func CheckConnStatus(blockId string) error

func HandleAppendBlockFile

func HandleAppendBlockFile(blockId string, blockFile string, data []byte) error

func HandleTruncateBlockFile

func HandleTruncateBlockFile(blockId string) error

func ResyncController

func ResyncController(ctx context.Context, tabId string, blockId string, rtOpts *waveobj.RuntimeOpts, force bool) error

func SendInput added in v0.11.6

func SendInput(blockId string, inputUnion *BlockInputUnion) error

func StopAllBlockControllers

func StopAllBlockControllers()

func StopBlockController

func StopBlockController(blockId string)

func StopBlockControllerAndSetStatus added in v0.10.0

func StopBlockControllerAndSetStatus(blockId string, newStatus string)

Types

type BlockControllerRuntimeStatus

type BlockControllerRuntimeStatus struct {
	BlockId           string `json:"blockid"`
	Version           int    `json:"version"`
	ShellProcStatus   string `json:"shellprocstatus,omitempty"`
	ShellProcConnName string `json:"shellprocconnname,omitempty"`
	ShellProcExitCode int    `json:"shellprocexitcode"`
	TsunamiPort       int    `json:"tsunamiport,omitempty"`
}

func GetBlockControllerRuntimeStatus added in v0.11.6

func GetBlockControllerRuntimeStatus(blockId string) *BlockControllerRuntimeStatus

type BlockInputUnion

type BlockInputUnion struct {
	InputData []byte            `json:"inputdata,omitempty"`
	SigName   string            `json:"signame,omitempty"`
	TermSize  *waveobj.TermSize `json:"termsize,omitempty"`
}

type ConnUnion added in v0.11.0

type ConnUnion struct {
	ConnName   string
	ConnType   string
	SshConn    *conncontroller.SSHConn
	WslConn    *wslconn.WslConn
	WshEnabled bool
	ShellPath  string
	ShellOpts  []string
	ShellType  string
}

type Controller added in v0.11.6

type Controller interface {
	Start(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error
	Stop(graceful bool, newStatus string) error
	GetRuntimeStatus() *BlockControllerRuntimeStatus
	SendInput(input *BlockInputUnion) error
}

Controller interface that all block controllers must implement

func MakeShellController added in v0.11.6

func MakeShellController(tabId string, blockId string, controllerType string) Controller

Constructor that returns the Controller interface

func MakeTsunamiController added in v0.11.6

func MakeTsunamiController(tabId string, blockId string) Controller

type RunShellOpts

type RunShellOpts struct {
	TermSize waveobj.TermSize `json:"termsize,omitempty"`
}

type ShellController added in v0.11.6

type ShellController struct {
	Lock *sync.Mutex

	// shared fields
	ControllerType string
	TabId          string
	BlockId        string
	BlockDef       *waveobj.BlockDef
	RunLock        *atomic.Bool
	ProcStatus     string
	ProcExitCode   int
	StatusVersion  int

	// for shell/cmd
	ShellProc    *shellexec.ShellProc
	ShellInputCh chan *BlockInputUnion
}

func (*ShellController) DoRunShellCommand added in v0.11.6

func (sc *ShellController) DoRunShellCommand(logCtx context.Context, rc *RunShellOpts, blockMeta waveobj.MetaMapType) error

func (*ShellController) GetRuntimeStatus added in v0.11.6

func (sc *ShellController) GetRuntimeStatus() *BlockControllerRuntimeStatus

func (*ShellController) LockRunLock added in v0.11.6

func (sc *ShellController) LockRunLock() bool

func (*ShellController) SendInput added in v0.11.6

func (sc *ShellController) SendInput(inputUnion *BlockInputUnion) error

func (*ShellController) Start added in v0.11.6

func (sc *ShellController) Start(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error

func (*ShellController) Stop added in v0.11.6

func (sc *ShellController) Stop(graceful bool, newStatus string) error

func (*ShellController) UnlockRunLock added in v0.11.6

func (sc *ShellController) UnlockRunLock()

func (*ShellController) UpdateControllerAndSendUpdate added in v0.11.6

func (sc *ShellController) UpdateControllerAndSendUpdate(updateFn func() bool)

func (*ShellController) WithLock added in v0.11.6

func (sc *ShellController) WithLock(f func())

type TsunamiAppProc added in v0.11.6

type TsunamiAppProc struct {
	Cmd          *exec.Cmd
	StdoutBuffer *utilds.ReaderLineBuffer
	StderrBuffer *utilds.ReaderLineBuffer // May be nil if stderr was consumed for port detection
	StdinWriter  io.WriteCloser
	Port         int           // Port the tsunami app is listening on
	WaitCh       chan struct{} // Channel that gets closed when cmd.Wait() returns
	WaitRtn      error         // Error returned by cmd.Wait()
}

type TsunamiController added in v0.11.6

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

func (*TsunamiController) GetRuntimeStatus added in v0.11.6

func (c *TsunamiController) GetRuntimeStatus() *BlockControllerRuntimeStatus

func (*TsunamiController) SendInput added in v0.11.6

func (c *TsunamiController) SendInput(input *BlockInputUnion) error

func (*TsunamiController) Start added in v0.11.6

func (c *TsunamiController) Start(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error

func (*TsunamiController) Stop added in v0.11.6

func (c *TsunamiController) Stop(graceful bool, newStatus string) error

func (*TsunamiController) WithStatusLock added in v0.11.6

func (c *TsunamiController) WithStatusLock(fn func())

Jump to

Keyboard shortcuts

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