Documentation
¶
Overview ¶
Package runners provides abstractions and utilities for working with different runner implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Available = map[string]RunnerCreator{
"go": newGolangRunner,
"py": newPythonRunner,
}
Available maps runner type strings (like "go" or "py") to their respective RunnerCreator functions. This allows for the dynamic creation of runners based on the runner type.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct { // TaskID is the unique identifier for the task that produced this result. TaskID string `json:"task_id"` // Ok indicates whether the task was successful. Ok bool `json:"ok"` // Output is the output of the task, if successful. Output string `json:"output"` // Duration is the amount of time it took for the task to complete. Duration float64 `json:"duration"` }
A Result represents the outcome of a Task.
type ResultOrError ¶
ResultOrError holds either the result of a task or an error. It is useful for communicating results and errors from asynchronous operations.
type Runner ¶
type Runner interface { // Start initializes the runner. Start() error // Stop terminates the runner. Stop() error // Cleanup handles any cleanup operations required after running a task. Cleanup() error // Run executes a given task and returns the result or an error. Run(task *Task) (*Result, error) String() string }
Runner is an interface defining methods for starting, stopping, cleaning up, and running tasks.
type RunnerCreator ¶
RunnerCreator is a function type that takes a directory string as input and returns a Runner. This allows for dynamic creation of different types of runners based on the provided directory.
type Task ¶
type Task struct { // TaskID is the unique identifier for the task. TaskID string `json:"task_id"` // Part is the part of the work that the task should perform. Part Part `json:"part"` // Input is the input data for the task. Input string `json:"input"` // OutputDir is the directory where the task should store its output. // This field is optional. OutputDir string `json:"output_dir,omitempty"` }
A Task represents a unit of work to be performed.