Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSystemContext ¶
func StartExecution ¶
StartExecution initializes and manages the execution of tasks based on the provided configuration. It validates the configuration, spawns worker goroutines, and processes tasks in batches.
Parameters:
- ctx: A context.Context object used to manage the lifecycle of the execution process.
- cfg: A Config object containing the execution parameters such as parallelism, batch size, command, and more.
Returns:
- error: Returns an error if the configuration is invalid or if the execution is prematurely terminated.
Behavior:
- Validates the provided configuration. If invalid, logs the error and terminates.
- Creates a channel for execution requests and spawns worker goroutines based on the configured parallelism.
- Processes tasks in batches, sending execution requests to the worker goroutines.
- Monitors the context for cancellation and ensures proper cleanup of resources.
- Waits for all worker goroutines to complete before returning.
Notes:
- The function ensures that the request channel is closed properly after use.
- If the context is canceled before completion, an error is returned, and the process is terminated.
Types ¶
type Config ¶
type ExecRequest ¶
type ExecRequest struct {
Command string
StdIn string
Offset int
BatchSize int
Shell string
ShellArgs []string
WorkingDirectory string
Timeout time.Duration
// contains filtered or unexported fields
}
ExecRequest represents a request to execute a command with specific parameters. It contains configuration options for the execution environment, command details, and logging preferences.
Fields: - rootCtx: The root context for the execution, used for cancellation and deadlines. - Command: The command to be executed. - Offset: The starting offset for processing, if applicable. - BatchSize: The size of the batch to process, if applicable. - Shell: The shell to use for executing the command. - ShellArgs: Additional arguments to pass to the shell. - WorkingDirectory: The directory in which the command should be executed. - Timeout: The maximum duration allowed for the command execution. - logRoot: The root directory for storing logs. - logToErr: A flag indicating whether logs should also be written to stderr.