extcmd

package
v1.8.16 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 6 Imported by: 4

Documentation

Overview

Package extcmd supports use cases in which a command is supposed be started non-blocking as a result of an incoming HTTP requests, e.g., ActionKit's start call. It allows retrieval of log messages for streaming to the agent as well as stopping and status access.

This package maintains state through a global variable that is a mapping from a random ID to CmdState. The random ID is contained within CmdState.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveCmdState

func RemoveCmdState(id string)

RemoveCmdState removes the state with the given ID. A no-op in case there is no state with this ID. It is the caller's responsibility to ensure that the exec.Cmd itself is stopped.

Types

type CmdState

type CmdState struct {
	Id  string
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

func GetCmdState

func GetCmdState(id string) (*CmdState, error)

GetCmdState returns the state stored under the given ID or an error in case there is no persisted state under the ID.

func NewCmdState

func NewCmdState(cmd *exec.Cmd) *CmdState

NewCmdState create a new CmdState and registers it as a global state. The expected call pattern is that NewCmdState is called immediately after the exec.Cmd is created, but before the Cmd is started.

func (*CmdState) GetLines

func (cs *CmdState) GetLines(includePartialLines bool) []string

func (*CmdState) GetMessages

func (cs *CmdState) GetMessages(includePartialMessages bool) []Message

func (*CmdState) Write

func (cs *CmdState) Write(p []byte) (n int, err error)

type Message

type Message struct {
	Level   *string `json:"level,omitempty"`
	Message string  `json:"message"`
}

Message is API compatible with ActionKit and DiscoveryKit Message

Jump to

Keyboard shortcuts

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