{"modulePath":"github.com/wavetermdev/waveterm","version":"v0.14.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package blockcontroller\n\n## Constants\n\n```go\nconst (\n\tBlockController_Shell   = \"shell\"\n\tBlockController_Cmd     = \"cmd\"\n\tBlockController_Tsunami = \"tsunami\"\n)\n```\n\n```go\nconst (\n\tStatus_Running = \"running\"\n\tStatus_Done    = \"done\"\n\tStatus_Init    = \"init\"\n)\n```\n\n```go\nconst (\n\tDefaultTermMaxFileSize = 2 * 1024 * 1024\n\tDefaultHtmlMaxFileSize = 256 * 1024\n\tMaxInitScriptSize      = 50 * 1024\n)\n```\n\n```go\nconst (\n\tConnType_Local = \"local\"\n\tConnType_Wsl   = \"wsl\"\n\tConnType_Ssh   = \"ssh\"\n)\n```\n\n```go\nconst DefaultGracefulKillWait = 400 * time.Millisecond\n```\n\n```go\nconst DefaultTimeout = 2 * time.Second\n```\n\n```go\nconst (\n\tLocalConnVariant_GitBash = \"gitbash\"\n)\n```\n\n## Functions\n\n```go\nfunc CheckConnStatus(blockId string) error\n```\n\n```go\nfunc DestroyBlockController(blockId string)\n```\n\n```go\nfunc HandleAppendBlockFile(blockId string, blockFile string, data []byte) error\n```\n\n```go\nfunc HandleTruncateBlockFile(blockId string) error\n```\n\n```go\nfunc InitBlockController()\n```\n\n```go\nfunc ResyncController(ctx context.Context, tabId string, blockId string, rtOpts *waveobj.RuntimeOpts, force bool) error\n```\n\n```go\nfunc SendInput(blockId string, inputUnion *BlockInputUnion) error\n```\n\n```go\nfunc StopAllBlockControllersForShutdown()\n```\nonly call this on shutdown\n\n## Types\n\n```go\ntype BlockControllerRuntimeStatus struct {\n\tBlockId           string `json:\"blockid\"`\n\tVersion           int64  `json:\"version\"`\n\tShellProcStatus   string `json:\"shellprocstatus,omitempty\"`\n\tShellProcConnName string `json:\"shellprocconnname,omitempty\"`\n\tShellProcExitCode int    `json:\"shellprocexitcode\"`\n\tTsunamiPort       int    `json:\"tsunamiport,omitempty\"`\n}\n```\n\n```go\nfunc GetBlockControllerRuntimeStatus(blockId string) *BlockControllerRuntimeStatus\n```\n\n```go\ntype BlockInputUnion struct {\n\tInputData []byte            `json:\"inputdata,omitempty\"`\n\tSigName   string            `json:\"signame,omitempty\"`\n\tTermSize  *waveobj.TermSize `json:\"termsize,omitempty\"`\n}\n```\n\n```go\ntype ConnUnion struct {\n\tConnName   string\n\tConnType   string\n\tSshConn    *conncontroller.SSHConn\n\tWslConn    *wslconn.WslConn\n\tWshEnabled bool\n\tShellPath  string\n\tShellOpts  []string\n\tShellType  string\n\tHomeDir    string\n}\n```\n\n```go\ntype Controller interface {\n\tStart(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error\n\tStop(graceful bool, newStatus string, destroy bool)\n\tGetRuntimeStatus() *BlockControllerRuntimeStatus // does not return nil\n\tGetConnName() string\n\tSendInput(input *BlockInputUnion) error\n}\n```\nController interface that all block controllers must implement\n\n```go\nfunc MakeDurableShellController(tabId string, blockId string, controllerType string, connName string) Controller\n```\n\n```go\nfunc MakeShellController(tabId string, blockId string, controllerType string, connName string) Controller\n```\nConstructor that returns the Controller interface\n\n```go\nfunc MakeTsunamiController(tabId string, blockId string, connName string) Controller\n```\n\n```go\ntype DurableShellController struct {\n\tLock *sync.Mutex\n\n\tControllerType string\n\tTabId          string\n\tBlockId        string\n\tConnName       string\n\tBlockDef       *waveobj.BlockDef\n\tVersionTs      utilds.VersionTs\n\n\tInputSessionId string // random uuid\n\n\tJobId           string\n\tLastKnownStatus string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (dsc *DurableShellController) GetConnName() string\n```\n\n```go\nfunc (dsc *DurableShellController) GetRuntimeStatus() *BlockControllerRuntimeStatus\n```\n\n```go\nfunc (dsc *DurableShellController) SendInput(inputUnion *BlockInputUnion) error\n```\n\n```go\nfunc (dsc *DurableShellController) Start(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error\n```\nStart 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:\n\n  - force=true: detaches old job and starts new one\n  - force=false: returns without starting (leaves block unstarted)\n\nAfter establishing jobId, ensures job connection is active (reconnects if needed)\n\n```go\nfunc (dsc *DurableShellController) Stop(graceful bool, newStatus string, destroy bool)\n```\n\n```go\nfunc (dsc *DurableShellController) WithLock(f func())\n```\n\n```go\ntype RunShellOpts struct {\n\tTermSize waveobj.TermSize `json:\"termsize,omitempty\"`\n}\n```\n\n```go\ntype ShellController struct {\n\tLock *sync.Mutex\n\n\t// shared fields\n\tControllerType string\n\tTabId          string\n\tBlockId        string\n\tConnName       string\n\tBlockDef       *waveobj.BlockDef\n\tRunLock        *atomic.Bool\n\tProcStatus     string\n\tProcExitCode   int\n\tVersionTs      utilds.VersionTs\n\n\t// for shell/cmd\n\tShellProc    *shellexec.ShellProc\n\tShellInputCh chan *BlockInputUnion\n}\n```\n\n```go\nfunc (sc *ShellController) DoRunShellCommand(logCtx context.Context, rc *RunShellOpts, blockMeta waveobj.MetaMapType) error\n```\n\n```go\nfunc (sc *ShellController) GetConnName() string\n```\n\n```go\nfunc (sc *ShellController) GetRuntimeStatus() *BlockControllerRuntimeStatus\n```\n\n```go\nfunc (sc *ShellController) LockRunLock() bool\n```\n\n```go\nfunc (sc *ShellController) SendInput(inputUnion *BlockInputUnion) error\n```\n\n```go\nfunc (sc *ShellController) Start(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error\n```\n\n```go\nfunc (sc *ShellController) Stop(graceful bool, newStatus string, destroy bool)\n```\n\n```go\nfunc (sc *ShellController) UnlockRunLock()\n```\n\n```go\nfunc (sc *ShellController) UpdateControllerAndSendUpdate(updateFn func() bool)\n```\n\n```go\nfunc (sc *ShellController) WithLock(f func())\n```\n\n```go\ntype TsunamiAppProc struct {\n\tCmd         *exec.Cmd\n\tLineBuffer  *utilds.MultiReaderLineBuffer\n\tStdinWriter io.WriteCloser\n\tPort        int           // Port the tsunami app is listening on\n\tWaitCh      chan struct{} // Channel that gets closed when cmd.Wait() returns\n\tWaitRtn     error         // Error returned by cmd.Wait()\n}\n```\n\n```go\ntype TsunamiController struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (c *TsunamiController) GetConnName() string\n```\n\n```go\nfunc (c *TsunamiController) GetRuntimeStatus() *BlockControllerRuntimeStatus\n```\n\n```go\nfunc (c *TsunamiController) SendInput(input *BlockInputUnion) error\n```\n\n```go\nfunc (c *TsunamiController) Start(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error\n```\n\n```go\nfunc (c *TsunamiController) Stop(graceful bool, newStatus string, destroy bool)\n```\n\n```go\nfunc (c *TsunamiController) WithStatusLock(fn func())\n```\n\n","path":"github.com/wavetermdev/waveterm/pkg/blockcontroller","name":"blockcontroller","synopsis":"","isRedistributable":true}
