core

package
v0.0.0-...-0a43815 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ROOT_NODE_NAME = "___ROOT___"

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// TaskGraph is a graph of package-tasks
	TaskGraph       *dag.AcyclicGraph
	PackageTaskDeps map[string][]string
	// contains filtered or unexported fields
}

Engine contains both the DAG for the packages and the tasks and implements the methods to execute tasks in them

func NewEngine

func NewEngine(
	completeGraph *graph.CompleteGraph,
	isSinglePackage bool,
) *Engine

NewEngine creates a new engine given a topologic graph of workspace package names

func (*Engine) AddDep

func (e *Engine) AddDep(fromTaskID string, toTaskID string) error

AddDep adds tuples from+to task ID combos in tuple format so they can be looked up later.

func (*Engine) AddTask

func (e *Engine) AddTask(taskName string)

AddTask adds root tasks to the engine so they can be looked up later.

func (*Engine) Execute

func (e *Engine) Execute(visitor Visitor, opts EngineExecutionOptions) []error

Execute executes the pipeline, constructing an internal task graph and walking it accordingly.

func (*Engine) Prepare

func (e *Engine) Prepare(options *EngineBuildingOptions) error

Prepare constructs the Task Graph for a list of packages and tasks

func (*Engine) ValidatePersistentDependencies

func (e *Engine) ValidatePersistentDependencies(graph *graph.CompleteGraph, concurrency int) error

ValidatePersistentDependencies checks if any task dependsOn persistent tasks and throws an error if that task is actually implemented

type EngineBuildingOptions

type EngineBuildingOptions struct {
	// Packages in the execution scope, if nil, all packages will be considered in scope
	Packages []string
	// TaskNames in the execution scope, if nil, all tasks will be executed
	TaskNames []string
	// Restrict execution to only the listed task names
	TasksOnly bool
}

EngineBuildingOptions help construct the TaskGraph

type EngineExecutionOptions

type EngineExecutionOptions struct {
	// Parallel is whether to run tasks in parallel
	Parallel bool
	// Concurrency is the number of concurrent tasks that can be executed
	Concurrency int
}

EngineExecutionOptions controls a single walk of the task graph

type MissingTaskError

type MissingTaskError struct {
	// contains filtered or unexported fields
}

MissingTaskError is a specialized Error thrown in the case that we can't find a task. We want to allow this error when getting task definitions, so we have to special case it.

func (*MissingTaskError) Error

func (m *MissingTaskError) Error() string

type StopExecutionSentinel

type StopExecutionSentinel struct {
	// contains filtered or unexported fields
}

StopExecutionSentinel is used to return an error from a graph Walk that indicates that all further walking should stop.

func StopExecution

func StopExecution(reason error) *StopExecutionSentinel

StopExecution wraps the given error in a sentinel error indicating that graph traversal should stop. Note that this will stop all tasks, not just downstream tasks.

func (*StopExecutionSentinel) Error

func (se *StopExecutionSentinel) Error() string

Error implements error.Error for StopExecutionSentinel

type Task

type Task struct {
	Name string
	// TaskDefinition contains the config for the task from turbo.json
	TaskDefinition fs.TaskDefinition
}

Task is a higher level struct that contains the underlying TaskDefinition but also some adjustments to it, based on business logic.

type Visitor

type Visitor = func(taskID string) error

Jump to

Keyboard shortcuts

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