apiflow

package
v0.0.0-...-ff2f935 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiFlow

type ApiFlow struct {
	// contains filtered or unexported fields
}

ApiFlow wraps a dependency tree to provide API execution logic

func NewApiFlow

func NewApiFlow(timeout time.Duration) *ApiFlow

NewApiFlow creates a new ApiFlow instance

func (*ApiFlow) AddNode

func (af *ApiFlow) AddNode(node *Node, upstreamIDs []string)

AddNode adds a node with dependencies to the flow

func (*ApiFlow) Run

func (af *ApiFlow) Run(ctx context.Context)

Run executes the API flow

type DependencyTree

type DependencyTree struct {
	// contains filtered or unexported fields
}

DependencyTree represents the entire tree structure

func NewDependencyTree

func NewDependencyTree() *DependencyTree

NewDependencyTree creates a new, empty dependency tree

func (*DependencyTree) AddNode

func (dt *DependencyTree) AddNode(node *Node, upstreamIDs []string)

AddNode adds a pre-created node to the dependency tree with its upstream dependencies

type Handler

type Handler func(ctx context.Context, node *Node, inputs map[string]interface{}) (interface{}, error)

Handler is a function associated with a node type It will be executed during traversal or as needed Returns an error to indicate failure

type Node

type Node struct {
	ID           string           // Unique identifier of the node
	Predecessors map[string]*Node // Nodes that are dependencies of this node
	Successors   map[string]*Node // Nodes that depend on this node
	Handler      Handler          // Handler function associated with the node
	State        string           // "pending", "success", "failure"
	Data         interface{}      // Data produced by this node
	Mutex        sync.Mutex       // To protect state and data modifications
}

func NewNode

func NewNode(id string, handler Handler) *Node

NewNode creates a new node without adding it to the tree

Jump to

Keyboard shortcuts

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