dag

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Dag provides a way to describe a directed acyclic graph of work to be done. It starts with a root node, then you add nodes to it. Outputs are automatically connected to subsequent inputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutionInfo

type ExecutionInfo struct {
	ID     string // External ID of the job
	Stdout string // Stdout of the job
	Stderr string // Stderr of the job
	Status string // Status of the job
}

type IOSpec

type IOSpec interface {
	NodeID() string
	ID() string
	CID() string
	Context() string
	Path() string
	IsRoot() bool
}

IOSpec is a generic input/output specification for a DAG

func NewIOSpec

func NewIOSpec(nodeID, id, value, path string, root bool, context string) IOSpec

type Node

type Node[T any] struct {
	// contains filtered or unexported fields
}

Node is a node in a directed acyclic graph. It has edges via links to child nodes.

func NewNode

func NewNode[T any](id string, job Work[T]) *Node[T]

func (*Node[T]) AddChild

func (n *Node[T]) AddChild(node *Node[T])

AddChild creates a child Node from some work

func (*Node[T]) AddRootInput added in v0.1.1

func (n *Node[T]) AddRootInput(input T)

func (*Node[T]) Children

func (n *Node[T]) Children() []*Node[T]

Children returns all the node's children

func (*Node[T]) Complete

func (n *Node[T]) Complete() bool

func (*Node[T]) Execute

func (n *Node[T]) Execute(ctx context.Context)

Internal method to execute the node and all its children given an input

func (*Node[T]) ID added in v0.1.0

func (n *Node[T]) ID() string

func (*Node[T]) Inputs

func (n *Node[T]) Inputs() []T

Input gets the inputs of a node

func (*Node[T]) IsRoot added in v0.1.1

func (n *Node[T]) IsRoot() bool

func (*Node[T]) Meta

func (n *Node[T]) Meta() NodeMetadata

Meta returns the node's metadata

func (*Node[T]) Outputs

func (n *Node[T]) Outputs() []T

Output gets the outputs of a node

func (*Node[T]) Parents

func (n *Node[T]) Parents() []*Node[T]

Parents returns all the node's parents

func (*Node[T]) Started

func (n *Node[T]) Started() bool

func (*Node[T]) Status

func (n *Node[T]) Status() NodeStatus

type NodeMetadata

type NodeMetadata struct {
	CreatedAt time.Time
	StartedAt time.Time
	EndedAt   time.Time
}

NodeMetadata contains metadata about a node

type NodeStatus

type NodeStatus struct {
	ID      string // External ID of the execution
	StdOut  string // Stdout of the execution
	StdErr  string // Stderr of the execution
	Status  string // Status of the execution
	Skipped bool   // Whether the execution was skipped
}

type Work

type Work[T any] func(ctx context.Context, inputs []T, statusChan chan NodeStatus) []T

Work is shorthand for a function that accepts inputs and returns outputs.

Jump to

Keyboard shortcuts

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