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 ¶
- Variables
- func Execute[T any](ctx context.Context, node Node[T])
- func GetDagStartTime[T any](ctx context.Context, dag []Node[T]) (time.Time, error)
- func GetEndTimeIfDagComplete[T any](ctx context.Context, dag []Node[T]) (time.Time, error)
- type ExecutionInfo
- type IOSpec
- type Node
- type NodeMetadata
- type NodeRepresentation
- type NodeResult
- type NodeSpec
- type NodeStore
- type Status
- type Work
- type WorkRepository
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWorkNotFound = fmt.Errorf("work not found") ErrWorkAlreadyExists = fmt.Errorf("work already exists") )
View Source
var (
MaxTime = time.Unix(1<<63-62135596801, 999999999)
)
Functions ¶
func GetDagStartTime ¶ added in v0.3.0
Types ¶
type ExecutionInfo ¶
type IOSpec ¶
type IOSpec interface {
NodeName() string // The node ID from the graph spec (not the internal node ID)
ID() string // The node's input ID from the graph spec
CID() string
Context() string
Path() string
IsRoot() bool
}
IOSpec is a generic input/output specification for a DAG
type Node ¶
type Node[T any] interface {
ID() int32
Get(context.Context) (NodeRepresentation[T], error)
AddChild(context.Context, Node[T]) error
AddParentChildRelationship(context.Context, Node[T]) error
AddParent(context.Context, Node[T]) error
AddInput(context.Context, T) error
AddOutput(context.Context, T) error
SetMetadata(context.Context, NodeMetadata) error
SetResults(context.Context, NodeResult) error
}
func FilterForRootNodes ¶ added in v0.3.0
type NodeMetadata ¶
type NodeMetadata struct {
CreatedAt time.Time
StartedAt time.Time
EndedAt time.Time
Status string // Status of the execution
}
NodeMetadata contains metadata about a node
type NodeRepresentation ¶ added in v0.3.0
type NodeRepresentation[T any] struct {
Id int32 // Keep track of the node's ID, useful during debugging
Name string // Name of the node
QueueItemID uuid.UUID // ID of the queue item
Work Work[T] // The work to be done by the node
Children []Node[T] // Children of the node
Parents []Node[T] // Parents of the node
Inputs []T // Input data
Outputs []T // Output data (which is fed into the inputs of its children)
Metadata NodeMetadata // Metadata about the node
Results NodeResult // Result of the node
}
type NodeResult ¶ added in v0.3.0
type NodeStore ¶ added in v0.3.0
type NodeStore[T any] interface {
NewNode(context.Context, NodeSpec[T]) (Node[T], error)
GetNode(context.Context, int32) (Node[T], error)
}
func NewNodeStore ¶ added in v0.3.0
func NewNodeStore(ctx context.Context, p db.NodePersistence, wr WorkRepository[IOSpec]) (NodeStore[IOSpec], error)
type Work ¶
type Work[T any] func(ctx context.Context, inputs []T, statusChan chan NodeResult) []T
Work is shorthand for a function that accepts inputs and returns outputs.
type WorkRepository ¶ added in v0.3.0
type WorkRepository[T any] interface {
Get(context.Context, int32) (Work[T], error)
Set(context.Context, int32, Work[T]) error
}
func NewInMemWorkRepository ¶ added in v0.3.0
func NewInMemWorkRepository[T any]() WorkRepository[T]
Click to show internal directories.
Click to hide internal directories.