group

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DepsGraph

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

DepsGraph is (intended to be) a directed acyclic graph that tracks the requirements dependencies between phases within a goal.

func NewDepsGraph

func NewDepsGraph(goal *Goal) *DepsGraph

NewDepsGraph constructs a DepsGraph or the given goal. Each task names the phases that must run before the phase to which the task belongs. The constructed directed acyclic graph (DAG) has edges pointing from the phase that must run earlier to the phases that may run only after that phase runs.

func (*DepsGraph) PhaseOrder

func (d *DepsGraph) PhaseOrder() ([]string, error)

PhaseOrder constructs an ordered list of phases based upon the DAG stored in DepsGraph. In the DAG, the most required nodes (vertices) will have no edges directed to them. Therefore, to produce a set of tasks that are grouped and ordered, we do the following:

  1. Find all unmarked nodes that have no edges pointing to them by unmarked nodes. This becomes the set of phases that may run. These will be ordered by name if there is more than one.

  2. Mark all the nodes found in (1).

  3. Repeat (1) and (2) until all nodes are marked.

The result is a slice of phase names in the order the phases must be run.

Along the way, it is possible for a cycle to be detected in the graph. If this occurs, it means that one or more task descriptions is misconfigured or that the mix of plugins have incompatible dependency requirements. In such a case, the error is reported with a description of a cycle.

type Goal

type Goal struct {
	// Name of the goal this group represents.
	Name string

	// Goal describes the goal for this group.
	Goal plugin.GoalDescription

	// Phases names all the phases for this goal and the tasks associated with
	// each phase.
	Phases map[string]*Phase

	// PhaseOrder is the order the phases should be run.
	PhaseOrder []string
}

Goal represents a top-level command. A goal is broken down into phases that run as a unit. Phases are run in a particular order based upon the run requirements of Tasks that are run in each phase. The Tasks run within a Phase are run concurrently and interleaved according to the Staging plan.

func SetupGroups

func SetupGroups(
	taskDescs []plugin.TaskDescription,
	goalDescs map[string]plugin.GoalDescription,
) ([]*Goal, error)

func (*Goal) Aliases

func (g *Goal) Aliases() []string

Aliases returns other names for this goal.

func (*Goal) ExecutionPhases

func (g *Goal) ExecutionPhases() []*Phase

ExecutionPhases returns the ordered list of Phases that are part of this Goal. The Phases will be logically executed in this order.

func (*Goal) Path

func (g *Goal) Path() string

Path returns the /goalName.

func (*Goal) Short

func (g *Goal) Short() string

Short returns the short description of the goal.

func (*Goal) Tasks

func (g *Goal) Tasks() []plugin.TaskDescription

Tasks returns the plugin.TaskDescription of all tasks that will run at some point as part of this Goal.

type Group

type Group interface {
	Path() string
}

type Phase

type Phase struct {
	// Goal is the goal to which this phase belongs.
	Goal *Goal

	// Name is the name fo the phase.
	Name string

	// InterleavedTasks is the list of tasks to be interleaved when running this
	// phase.
	InterleavedTasks []*Task
	// contains filtered or unexported fields
}

Phase makes up part of the overall execution plan of a Goal. It represents a single unit of execution that shares state between the Tasks that are run within concurrently and interleaved according to the Staging plan.

func (*Phase) Context

func (p *Phase) Context(
	logger *log.Logger,
	properties storage.KV,
) *plugin.Context

Context returns the plugin.Context that all tasks within this phase share. The given logger and properties are used to initialize the context object if it has not been initialized yet.

func (*Phase) Path

func (p *Phase) Path() string

Path returns the /goalName/phaseName path.

func (*Phase) Short

func (p *Phase) Short() string

Short returns the short description of the phase, as built from the tasks.

func (*Phase) Tasks

func (p *Phase) Tasks() []plugin.TaskDescription

Tasks returns the plugin.TaskDescription for all the tasks that will be executed during this Phase.

type PhaseGroup

type PhaseGroup interface {
	ExecutionPhases() []*Phase
}

type Task

type Task struct {
	// Phase is the phase to which this task belongs.
	Phase *Phase

	// Name is the name of the Task to run.
	Name string

	// Task is the description of this task.
	Task plugin.TaskDescription
}

Task is the smallest unit of execution. Normally, a Task is executed concurrently with other Tasks and shares state with them while running as part of a Phase.

func (*Task) Path

func (t *Task) Path() string

Path returns the /goalName/phaseName/taskName path.

func (*Task) Short

func (t *Task) Short() string

Short returns a short description of what the task does.

func (*Task) Tasks

func (t *Task) Tasks() []plugin.TaskDescription

Tasks returns just this task.

type TaskGroup

type TaskGroup interface {
	Tasks() []plugin.TaskDescription
}

Jump to

Keyboard shortcuts

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