Documentation ¶
Overview ¶
Package node define action, and decision nodes.
You can also create your own node if the struct respect the Node interface. A Node use a Context during computation as input data and output data.
NOTE: you will also find a "go-cmp" comparator for Node.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // NodeComparator is a google/go-cmp comparator of Node NodeComparator = cmp.Comparer(func(x, y Node) bool { return x == y }) )
Functions ¶
This section is empty.
Types ¶
type ActionNode ¶
type ActionNode struct {
// contains filtered or unexported fields
}
ActionNode is a type of Node who compute a function to realize some actions based on Context.
func NewAction ¶
func NewAction(name string, actionFunc func(*Context) error) (*ActionNode, error)
NewAction create a ActionNode based on a name and a function to realize the needed action.
func (*ActionNode) Compute ¶
func (n *ActionNode) Compute(c *Context) computestate.ComputeState
Compute run the action function and decide which compute state to return.
func (*ActionNode) DecideCapability ¶
func (n *ActionNode) DecideCapability() bool
DecideCapability is desactived due to the fact that an action don't take a decision.
func (ActionNode) String ¶
func (n ActionNode) String() string
type Context ¶
type Context struct {
Data map[string]interface{}
}
Context hold data during an Computation
func NewContext ¶
NewContext generate a new Context with data
func NewContextWithoutData ¶
func NewContextWithoutData() *Context
NewContextWithoutData generate a new empty Context
type DecisionNode ¶
type DecisionNode struct {
// contains filtered or unexported fields
}
DecisionNode is a type of Node who compute a function to take a decision based on Context.
func NewDecision ¶
NewDecision create a DecisionNode based on a name and a function to take the needed decision.
func (*DecisionNode) Compute ¶
func (n *DecisionNode) Compute(c *Context) computestate.ComputeState
Compute run the decision function and decide which compute state to return.
func (*DecisionNode) DecideCapability ¶
func (n *DecisionNode) DecideCapability() bool
DecideCapability is actived due to the fact that an decision is taked during compute.
func (DecisionNode) String ¶
func (n DecisionNode) String() string
type Node ¶
type Node interface { // Compute a node based on a context Compute(c *Context) computestate.ComputeState // DecideCapability tell if the Node can decide. // This impact the compute state by adding a branch to the state. DecideCapability() bool }
Node define