Documentation
¶
Index ¶
- func BindNodes[T interface{}](parent *Node[T], siblings ...*Node[T])
- func BuildChain[T interface{}](stopChain *chan int, nodes ...*Node[T])
- func Flow[T interface{}](ctx *FlowContext, n *Node[T], i T, SubNodeIndex int, LateralNodeIndex int, ...)
- func StartFlow[T interface{}](ctx *FlowContext, n *Node[T])
- type AbortError
- type CircularNodePolicy
- type FlowContext
- type Input
- type Node
- type NodeTrail
- type Output
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindNodes ¶
BindNodes links the parent to the sub nodes and each sub node laterally to each other.
func BuildChain ¶
BuildChain will bind nodes into a chain which just means that the last node will have the first node as a sibling. Does not bind any siblings and no siblings should be set manually. The usecase for this would be running an refresh loop that has a lifetime which usually would equal that of the program.
func Flow ¶
func Flow[T interface{}](ctx *FlowContext, n *Node[T], i T, SubNodeIndex int, LateralNodeIndex int, err error)
Flow initiates each node sequentially from the start node downstream to all sub nodes. If a parent has more than one sub node, the higher index nodes are fallback nodes. Should the first of the siblings fail, the next lateral node will execute from the siblings slice. If all nodes from a level error out then the context of the flow will be canceled.
func StartFlow ¶
func StartFlow[T interface{}](ctx *FlowContext, n *Node[T])
StartFlow is an alias for calling Flow with the arguments as Flow(ctx, n, nil, 0, 0, nil)
Types ¶
type AbortError ¶
type AbortError struct {
Message string
}
func (AbortError) Error ¶
func (err AbortError) Error() string
type CircularNodePolicy ¶
type CircularNodePolicy struct { Timeout time.Duration RequiredForSuccess bool RestartOnError bool IsCircularNode bool StopChain *chan int }
CircularNodePolicy enforces a shutdown procedure for the chain iteration
type FlowContext ¶
type FlowContext struct { Ctx context.Context Cancel context.CancelFunc }
Initialized context and cancel func need to be populated
func (*FlowContext) Init ¶
func (c *FlowContext) Init()
func (*FlowContext) IsCanceled ¶
func (c *FlowContext) IsCanceled() (bool, error)
type Node ¶
type Node[T interface{}] struct { Name string // Name of the node ParentNode *Node[T] // Parent node SubNodes []*Node[T] // Children nodes Siblings []*Node[T] // Lateral nodes Task func(*FlowContext, T) (T, error) // Task that should be processed Input T // Input payload, nil if starting node Output T // Output payload FlowTrail []string // The order in which nodes were executed NodeTrail NodeTrail // Meta data populated after node processing finishes Context *FlowContext // Pointer to the flow context CircularNodePolicy CircularNodePolicy // Policy for circular nodes }