blockcontroller

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 42 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
View Source
const (
	LocalConnVariant_GitBash = "gitbash"
)

Variables

This section is empty.

Functions

func CheckConnStatus

func CheckConnStatus(blockId string) error

func DestroyBlockController

func DestroyBlockController(blockId string)

func HandleAppendBlockFile

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

func HandleTruncateBlockFile

func HandleTruncateBlockFile(blockId string) error

func InitBlockController

func InitBlockController()

func ResyncController

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

func SendInput

func SendInput(blockId string, inputUnion *BlockInputUnion) error

func StopAllBlockControllersForShutdown

func StopAllBlockControllersForShutdown()

only call this on shutdown

Types

type BlockControllerRuntimeStatus

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

func GetBlockControllerRuntimeStatus

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

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

type Controller

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

Controller interface that all block controllers must implement

func MakeDurableShellController

func MakeDurableShellController(tabId string, blockId string, controllerType string, connName string) Controller

func MakeShellController

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

Constructor that returns the Controller interface

func MakeTsunamiController

func MakeTsunamiController(tabId string, blockId string, connName string) Controller

type DurableShellController

type DurableShellController struct {
	Lock *sync.Mutex

	ControllerType string
	TabId          string
	BlockId        string
	ConnName       string
	BlockDef       *waveobj.BlockDef
	VersionTs      utilds.VersionTs

	InputSessionId string // random uuid

	JobId           string
	LastKnownStatus string
	// contains filtered or unexported fields
}

func (*DurableShellController) GetConnName

func (dsc *DurableShellController) GetConnName() string

func (*DurableShellController) GetRuntimeStatus

func (dsc *DurableShellController) GetRuntimeStatus() *BlockControllerRuntimeStatus

func (*DurableShellController) SendInput

func (dsc *DurableShellController) SendInput(inputUnion *BlockInputUnion) error

func (*DurableShellController) Start

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

Start initializes or reconnects to a durable shell for the block. Logic: - If block has no existing jobId: starts a new job and attaches it - If block has existing jobId with running job manager: reconnects to existing job - If block has existing jobId with non-running job manager:

  • force=true: detaches old job and starts new one
  • force=false: returns without starting (leaves block unstarted)

After establishing jobId, ensures job connection is active (reconnects if needed)

func (*DurableShellController) Stop

func (dsc *DurableShellController) Stop(graceful bool, newStatus string, destroy bool)

func (*DurableShellController) WithLock

func (dsc *DurableShellController) WithLock(f func())

type RunShellOpts

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

type ShellController

type ShellController struct {
	Lock *sync.Mutex

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

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

func (*ShellController) DoRunShellCommand

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

func (*ShellController) GetConnName

func (sc *ShellController) GetConnName() string

func (*ShellController) GetRuntimeStatus

func (sc *ShellController) GetRuntimeStatus() *BlockControllerRuntimeStatus

func (*ShellController) LockRunLock

func (sc *ShellController) LockRunLock() bool

func (*ShellController) SendInput

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

func (*ShellController) Start

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

func (*ShellController) Stop

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

func (*ShellController) UnlockRunLock

func (sc *ShellController) UnlockRunLock()

func (*ShellController) UpdateControllerAndSendUpdate

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

func (*ShellController) WithLock

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

type TsunamiAppProc

type TsunamiAppProc struct {
	Cmd         *exec.Cmd
	LineBuffer  *utilds.MultiReaderLineBuffer
	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

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

func (*TsunamiController) GetConnName

func (c *TsunamiController) GetConnName() string

func (*TsunamiController) GetRuntimeStatus

func (c *TsunamiController) GetRuntimeStatus() *BlockControllerRuntimeStatus

func (*TsunamiController) SendInput

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

func (*TsunamiController) Start

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

func (*TsunamiController) Stop

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

func (*TsunamiController) WithStatusLock

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

Jump to

Keyboard shortcuts

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