tree

package
v0.0.0-...-4b48589 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandType     = "command"
	DecisionType    = "decision"
	DestinationType = "destination"
)

Variables

This section is empty.

Functions

func CommandNodeType

func CommandNodeType() mesh.NodeType

func Decide

func Decide(m mesh.Node, input interface{}) error

Decide executes the decision command with the input. The input is expected to be unchanged. The outcome of a decision is a list of categories names. These categories are used to identify the next nodes to call.

func DecisionNodeType

func DecisionNodeType() mesh.NodeType

func DestinationNodeType

func DestinationNodeType() mesh.NodeType

func ExecuteCommand

func ExecuteCommand(m mesh.Node, input interface{}) error

ExecuteCommand executes the command and checks if the input and return types match the expected types.

func ExecuteNodes

func ExecuteNodes(nodes []mesh.Node, input interface{}, executorName string) error

func GetCommandFromMap

func GetCommandFromMap(content map[string]interface{}) interface{}

func GetDecisionFromMap

func GetDecisionFromMap(content map[string]interface{}) interface{}

func GetDestinationFromMap

func GetDestinationFromMap(content map[string]interface{}) interface{}

func NewCommandNode

func NewCommandNode(title string, execFunction func(interface{}) (interface{}, error), inputType, returnType interface{}) (mesh.Node, error)

NewCommandNode creates a new command node

func NewDecisionNode

func NewDecisionNode(title string, execFunction func(interface{}) ([]string, error), valueType, returnType interface{}) (mesh.Node, error)

NewDecisionNode creates a new decision node.

func NewDestinationNode

func NewDestinationNode(title string, execFunction func(interface{}) error, inputType, returnType interface{}) (mesh.Node, error)

NewDestinationNode creates a new destination node

func Terminate

func Terminate(m mesh.Node, input interface{}) error

Terminate executes the terminal command with the input.

Types

type Command

type Command struct {
	Name               string      `json:"name"`
	ExpectedInputType  interface{} `json:"inputtype"`
	ExpectedReturnType interface{} `json:"returntype"`
	// contains filtered or unexported fields
}

Command is a step in a branch of a decision tree. It is expected that execute function acquire and manipulate data to prepare a next Command, a Decision or a Destination.

type Decision

type Decision struct {
	Name              string `json:"name"`
	ExpectedValueType interface{}
	// contains filtered or unexported fields
}

Decision divides a branch of a decision tree in to multiple subbranches. It is expected that decide function returns a list of categories names, which are used to identify the next nodes to call.

type Destination

type Destination struct {
	Name              string `json:"name"`
	ExpectedInputType interface{}
	// contains filtered or unexported fields
}

Destination terminates a branch of a decision tree. It is expected that terminate function does an action to fulfill the purpose of the branch.

Jump to

Keyboard shortcuts

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