Documentation
¶
Index ¶
- type Dag
- func (d *Dag) DependencyAdd(dependent RunnableInterface, dependency ...RunnableInterface)
- func (d *Dag) DependencyList(ctx context.Context, node RunnableInterface, data map[string]any) []RunnableInterface
- func (d *Dag) GetID() string
- func (d *Dag) GetName() string
- func (d *Dag) Run(ctx context.Context, data map[string]any) (context.Context, map[string]any, error)
- func (d *Dag) RunnableAdd(node ...RunnableInterface)
- func (d *Dag) RunnableList() []RunnableInterface
- func (d *Dag) RunnableRemove(node RunnableInterface) bool
- func (d *Dag) SetID(id string)
- func (d *Dag) SetName(name string)
- type DagInterface
- type PipelineInterface
- type RunnableInterface
- type Step
- func (s *Step) GetHandler() StepHandler
- func (s *Step) GetID() string
- func (s *Step) GetName() string
- func (s *Step) Run(ctx context.Context, data map[string]any) (context.Context, map[string]any, error)
- func (s *Step) SetHandler(fn StepHandler)
- func (s *Step) SetID(id string)
- func (s *Step) SetName(name string)
- type StepHandler
- type StepInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dag ¶
type Dag struct {
// contains filtered or unexported fields
}
func (*Dag) DependencyAdd ¶
func (d *Dag) DependencyAdd(dependent RunnableInterface, dependency ...RunnableInterface)
DependencyAdd adds a dependency between two nodes.
func (*Dag) DependencyList ¶
func (d *Dag) DependencyList(ctx context.Context, node RunnableInterface, data map[string]any) []RunnableInterface
DependencyList returns all dependencies for a given node.
func (*Dag) Run ¶
func (d *Dag) Run(ctx context.Context, data map[string]any) (context.Context, map[string]any, error)
Run executes all nodes in the DAG in the correct order
func (*Dag) RunnableAdd ¶
func (d *Dag) RunnableAdd(node ...RunnableInterface)
RunnableAdd adds a single node to the DAG.
func (*Dag) RunnableList ¶
func (d *Dag) RunnableList() []RunnableInterface
RunnableList returns all runnable nodes in the DAG.
func (*Dag) RunnableRemove ¶
func (d *Dag) RunnableRemove(node RunnableInterface) bool
RunnableRemove removes a node from the DAG.
type DagInterface ¶
type DagInterface interface {
RunnableInterface
// RunnableAdd adds a single node to the DAG.
// Runnable nodes can be added in any order, as their execution order will be determined by their dependencies.
RunnableAdd(node ...RunnableInterface)
// RunnableRemove removes a node from the DAG.
// Returns true if the node was found and removed, false if it wasn't found.
RunnableRemove(node RunnableInterface) bool
// RunnableList returns all runnable nodes in the DAG.
// The order of nodes in the returned slice is not guaranteed to be their execution order.
// Use Run() to execute nodes in the correct order based on their dependencies.
RunnableList() []RunnableInterface
// DependencyAdd adds a dependency between two nodes.
// The dependent node will only execute after the dependency node has completed successfully.
DependencyAdd(dependent RunnableInterface, dependency ...RunnableInterface)
// DependencyList returns all dependencies for a given node.
// The actual dependencies may vary based on the context and any conditional dependencies.
DependencyList(ctx context.Context, node RunnableInterface, data map[string]any) []RunnableInterface
}
DagInterface represents a Directed Acyclic Graph (DAG) of steps that can be executed in a specific order. It manages the dependencies between steps and ensures they are executed in the correct sequence.
type PipelineInterface ¶
type PipelineInterface interface {
RunnableInterface
// RunnableAdd adds a runnable node(s) to the pipeline.
RunnableAdd(node ...RunnableInterface)
// RunnableRemove removes a runnable node from the pipeline.
RunnableRemove(node RunnableInterface) bool
// RunnableList returns all runnable nodes in the pipeline.
// The order of nodes in the returned slice is the order they were added.
RunnableList() []RunnableInterface
}
PipelineInterface represents a sequence of runnable nodes that will be executed in the sequence they are added.
func NewPipeline ¶
func NewPipeline() PipelineInterface
type RunnableInterface ¶
type RunnableInterface interface {
GetID() string
SetID(id string)
GetName() string
SetName(name string)
Run(ctx context.Context, data map[string]any) (context.Context, map[string]any, error)
}
RunnableInterface represents a single unit of work, that can be executed within a given context, and specified data. It can work wuth the data and return the result of the work.
It can be used as a single step, or combined with other nodes to form a Pipeline, Workflow or DAG.
type Step ¶
type Step struct {
// contains filtered or unexported fields
}
func (*Step) GetHandler ¶
func (s *Step) GetHandler() StepHandler
GetHandler returns the step's execution function
func (*Step) Run ¶
func (s *Step) Run(ctx context.Context, data map[string]any) (context.Context, map[string]any, error)
Run executes the step's function with the given context
func (*Step) SetHandler ¶
func (s *Step) SetHandler(fn StepHandler)
SetHandler sets the step's execution function
type StepHandler ¶
type StepInterface ¶
type StepInterface interface {
RunnableInterface
// GetHandler returns the function that implements the step's execution logic.
GetHandler() StepHandler
// SetHandler allows setting or modifying the step's execution logic.
SetHandler(handler StepHandler)
}
StepInterface represents a single node in a Pipeline, Workflow or DAG. A step is a unit of work that can be executed within a given context. A step is executed by a Pipeline, Workflow or DAG which manages its dependencies and execution order.
func NewStep ¶
func NewStep() StepInterface
NewStep creates a new step with the given execution function and optional ID.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
dag_conditional_logic
command
|
|
|
dag_dependencies
command
|
|
|
dag_error_handling
command
|