executor

package
v0.0.0-...-2fc0378 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockToLegacyName

func BlockToLegacyName(block command.BlockType) string

BlockToLegacyName converts the name of a command block to the name it has in the logging format.

func RunCommandsInBlock

func RunCommandsInBlock(ctx context.Context, deps BlockExecutorDeps, cmdBlock CommandBlock) (err error)

RunCommandsInBlock executes all commands in a block and can be integrated into agent task execution and local task execution.

Types

type BlockExecutorDeps

type BlockExecutorDeps struct {
	JasperManager jasper.Manager
	Tracer        trace.Tracer
	TaskLogger    grip.Journaler
	ExecLogger    grip.Journaler
	TaskConfig    *internal.TaskConfig

	// StartTimeoutWatcher starts a goroutine that cancels the context when the timeout is reached. If
	// nil, no timeout watcher is started.
	StartTimeoutWatcher func(ctx context.Context, cancel context.CancelFunc, kind globals.TimeoutType, getTimeout func() time.Duration, canMarkFailure bool)

	// SetHeartbeatTimeout sets the heartbeat timeout for the task. If nil, heartbeat timeouts are not modified.
	// This is only used in the agent to set heartbeat timeouts for blocks that can timeout.
	SetHeartbeatTimeout func(startAt time.Time, getTimeout func() time.Duration, kind globals.TimeoutType)

	// ResetHeartbeatTimeout resets the heartbeat timeout to default. If nil, heartbeat timeouts are not reset.
	// Only used by the agent to restore default heartbeat timeout after a block completes.
	ResetHeartbeatTimeout func()

	// HandlePanic handles panics that occur during command execution.
	HandlePanic func(ctx context.Context, panicErr error, originalErr error, op string) error

	// RunCommandOrFunc executes a command or function. If nil, commands are not executed.
	RunCommandOrFunc func(ctx context.Context, commandInfo model.PluginCommandConf, cmds []command.Command, block command.BlockType, canFailTask bool) error
}

BlockExecutorDeps contains all dependencies needed for command block execution. This uses composition instead of complex interfaces to share logic between Agent and LocalTaskExecutor.

type CommandBlock

type CommandBlock struct {
	Block               command.BlockType
	Commands            *model.YAMLCommandSet
	TimeoutKind         globals.TimeoutType
	GetTimeout          func() time.Duration
	CanTimeOutHeartbeat bool
	CanFailTask         bool
}

CommandBlock contains information for a block of commands.

Jump to

Keyboard shortcuts

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