blockcontroller

package
v0.14.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 41 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 added in v0.14.0

func DestroyBlockController(blockId string)

func HandleAppendBlockFile

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

func HandleTruncateBlockFile

func HandleTruncateBlockFile(blockId string) error

func InitBlockController added in v0.14.0

func InitBlockController()

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 StopAllBlockControllersForShutdown added in v0.14.0

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 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
	HomeDir    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, destroy bool)
	GetRuntimeStatus() *BlockControllerRuntimeStatus // does not return nil
	GetConnName() string
	SendInput(input *BlockInputUnion) error
}

Controller interface that all block controllers must implement

func MakeDurableShellController added in v0.14.0

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

func MakeShellController added in v0.11.6

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

Constructor that returns the Controller interface

func MakeTsunamiController added in v0.11.6

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

type DurableShellController added in v0.14.0

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 added in v0.14.0

func (dsc *DurableShellController) GetConnName() string

func (*DurableShellController) GetRuntimeStatus added in v0.14.0

func (dsc *DurableShellController) GetRuntimeStatus() *BlockControllerRuntimeStatus

func (*DurableShellController) SendInput added in v0.14.0

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

func (*DurableShellController) Start added in v0.14.0

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 added in v0.14.0

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

func (*DurableShellController) WithLock added in v0.14.0

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

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
	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 added in v0.11.6

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

func (*ShellController) GetConnName added in v0.14.0

func (sc *ShellController) GetConnName() string

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, destroy bool)

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
	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 added in v0.11.6

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

func (*TsunamiController) GetConnName added in v0.14.0

func (c *TsunamiController) GetConnName() string

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, destroy bool)

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