Documentation
¶
Index ¶
- Variables
- func CommonRequest(backendName string, proc Commander, logger *slog.Logger, url string, ...) error
- func GetList() []string
- func HaveBackend(name string) bool
- func Register(name string, b Backend)
- type Backend
- type CmdOptions
- type CmdStatus
- type CmdWrapper
- type Commander
- type RunningStatus
- type State
Constants ¶
This section is empty.
Variables ¶
var NewCmdOptions = func(options CmdOptions, name string, args ...string) Commander { cmdOptions := cmd.Options{ Buffered: options.Buffered, Streaming: options.Streaming, } return &CmdWrapper{Cmd: cmd.NewCmdOptions(cmdOptions, name, args...)} }
NewCmdOptions creates a new command with specific options
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
Configure(*slog.Logger, policies.PolicyRepo, map[string]any, config.BackendCommons) error
Version() (string, error)
Start(ctx context.Context, cancelFunc context.CancelFunc) error
Stop(ctx context.Context) error
FullReset(ctx context.Context) error
GetStartTime() time.Time
GetCapabilities() (map[string]any, error)
GetRunningStatus() (RunningStatus, string, error)
GetInitialState() RunningStatus
ApplyPolicy(data policies.PolicyData, updatePolicy bool) error
RemovePolicy(data policies.PolicyData) error
}
Backend is the interface that all backends must implement
type CmdOptions ¶
type CmdOptions struct {
Buffered bool // Whether to buffer the output
Streaming bool // Whether to stream the output
}
CmdOptions holds the options for command execution
type CmdStatus ¶
type CmdStatus struct {
PID int // Process ID of command
Complete bool // Whether the command has completed
Exit int // Exit code of the command
Error error // Go error
StopTs int64 // Timestamp when the command was stopped
}
CmdStatus holds the status of a command
func ConvertStatus ¶
ConvertStatus converts cmd.Status to our Status
type CmdWrapper ¶
CmdWrapper wraps the cmd.Cmd struct to implement CmdInterface
func (*CmdWrapper) GetStderr ¶
func (c *CmdWrapper) GetStderr() <-chan string
GetStderr returns the stderr channel
func (*CmdWrapper) GetStdout ¶
func (c *CmdWrapper) GetStdout() <-chan string
GetStdout returns the stdout channel
func (*CmdWrapper) Start ¶
func (c *CmdWrapper) Start() <-chan CmdStatus
Start starts the command and returns a channel for its status
func (*CmdWrapper) Status ¶
func (c *CmdWrapper) Status() CmdStatus
Status returns the current command status
type Commander ¶
type Commander interface {
Start() <-chan CmdStatus
Stop() error
Status() CmdStatus
// For accessing output channels
GetStdout() <-chan string
GetStderr() <-chan string
}
Commander abstracts the functionality from go-cmd/cmd package
type RunningStatus ¶
type RunningStatus int
RunningStatus is the status of the backend
const ( Unknown RunningStatus = iota Running BackendError AgentError Offline Waiting )
Running Status types
func GetRunningStatus ¶
func GetRunningStatus(proc Commander) (RunningStatus, string, error)
GetRunningStatus checks the status of the backend process
func (RunningStatus) String ¶
func (s RunningStatus) String() string