executor

package
v0.0.0-...-17d9e29 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypeSafetyCheck

func TypeSafetyCheck(name string, value string, argumentType string) error

TypeSafetyCheck checks argument values match a specific type. The types are defined in typecheckRegex, and, you guessed it, uses regex to check for allowed characters.

Types

type ActionBinding

type ActionBinding struct {
	Action       *config.Action
	EntityPrefix string
	ConfigOrder  int
}

type ExecutionRequest

type ExecutionRequest struct {
	ActionTitle       string
	Action            *config.Action
	Arguments         map[string]string
	TrackingID        string
	Tags              []string
	Cfg               *config.Config
	AuthenticatedUser *acl.AuthenticatedUser
	EntityPrefix      string
	// contains filtered or unexported fields
}

ExecutionRequest is a request to execute an action. It's passed to an Executor. They're created from the grpcapi.

type Executor

type Executor struct {
	LogsByActionId map[string][]*InternalLogEntry

	MapActionIdToBinding     map[string]*ActionBinding
	MapActionIdToBindingLock sync.RWMutex

	Cfg *config.Config
	// contains filtered or unexported fields
}

Executor represents a helper class for executing commands. It's main method is ExecRequest

func DefaultExecutor

func DefaultExecutor(cfg *config.Config) *Executor

DefaultExecutor returns an Executor, with a sensible "chain of command" for executing actions.

func (*Executor) AddListener

func (e *Executor) AddListener(m listener)

func (*Executor) ExecRequest

func (e *Executor) ExecRequest(req *ExecutionRequest) (*sync.WaitGroup, string)

ExecRequest processes an ExecutionRequest

func (*Executor) FindActionBindingByID

func (e *Executor) FindActionBindingByID(id string) *config.Action

func (*Executor) GetLog

func (e *Executor) GetLog(trackingID string) (*InternalLogEntry, bool)

func (*Executor) GetLogsByActionId

func (e *Executor) GetLogsByActionId(actionId string) []*InternalLogEntry

func (*Executor) GetLogsCopy

func (e *Executor) GetLogsCopy() map[string]*InternalLogEntry

func (*Executor) Kill

func (e *Executor) Kill(execReq *InternalLogEntry) error

func (*Executor) RebuildActionMap

func (e *Executor) RebuildActionMap()

func (*Executor) SetLog

func (e *Executor) SetLog(trackingID string, entry *InternalLogEntry)

type InternalLogEntry

type InternalLogEntry struct {
	DatetimeStarted     time.Time
	DatetimeFinished    time.Time
	Output              string
	TimedOut            bool
	Blocked             bool
	ExitCode            int32
	Tags                []string
	ExecutionStarted    bool
	ExecutionFinished   bool
	ExecutionTrackingID string
	Process             *os.Process
	Username            string

	/*
		The following 3 properties are obviously on Action normally, but it's useful
		that logs are lightweight (so we don't need to have an action associated to
		logs, etc. Therefore, we duplicate those values here.
	*/
	ActionTitle string
	ActionIcon  string
	ActionId    string
}

InternalLogEntry objects are created by an Executor, and represent the final state of execution (even if the command is not executed). It's designed to be easily serializable.

type OutputStreamer

type OutputStreamer struct {
	Req *ExecutionRequest
	// contains filtered or unexported fields
}

func (*OutputStreamer) String

func (ost *OutputStreamer) String() string

func (*OutputStreamer) Write

func (ost *OutputStreamer) Write(o []byte) (n int, err error)

Jump to

Keyboard shortcuts

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