Documentation
¶
Index ¶
- type AgentNode
- type Condition
- type DefaultScheduler
- type Edge
- type FuncNode
- type Graph
- func (g *Graph) Edge(from, to string, cond ...Condition) *Graph
- func (g *Graph) Execute(ctx context.Context, state *State) (*Result, error)
- func (g *Graph) ID() string
- func (g *Graph) Node(id string, node Node) *Graph
- func (g *Graph) SetLimiter(limiter ratelimit.Limiter) *Graph
- func (g *Graph) SetScheduler(scheduler Scheduler) *Graph
- func (g *Graph) SetTracer(tracer observability.Tracer) *Graph
- func (g *Graph) Start(id string) *Graph
- type Node
- type PriorityScheduler
- type Result
- type Scheduler
- type ShortJobScheduler
- type State
- type ToolNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentNode ¶
type AgentNode struct {
// contains filtered or unexported fields
}
AgentNode wraps an existing agent to be used as a node.
func NewAgentNode ¶
NewAgentNode creates a new agent node.
NOTE: This function will panic if agent is nil. This is intentional as it indicates a programming error in the calling code. These constructors are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: agent - agent instance, must not be nil. Returns new agent node.
type DefaultScheduler ¶
type DefaultScheduler struct{}
DefaultScheduler provides FIFO scheduling, consistent with Workflow Engine.
func NewDefaultScheduler ¶
func NewDefaultScheduler() *DefaultScheduler
NewDefaultScheduler creates a new default scheduler.
func (*DefaultScheduler) Select ¶
func (s *DefaultScheduler) Select(ready []string) string
Select returns the first ready node (FIFO).
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
Edge represents a connection between two nodes with optional condition.
type FuncNode ¶
type FuncNode struct {
// contains filtered or unexported fields
}
FuncNode wraps a simple function to be used as a node.
func NewFuncNode ¶
NewFuncNode creates a new function node.
NOTE: This function will panic if id is empty or fn is nil. This is intentional as it indicates a programming error in the calling code. These constructors are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: id - unique node identifier, must not be empty. fn - function to execute, must not be nil. Returns new function node.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represents a DAG of nodes with conditional edges.
func NewGraph ¶
NewGraph creates a new graph with the given ID.
NOTE: This function will panic if id is empty. This is intentional as it indicates a programming error in the calling code. This constructor is used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: id - unique graph identifier, must not be empty. Returns new graph instance.
func NewGraphWithLimiter ¶
NewGraphWithLimiter creates a new graph with a custom rate limiter.
NOTE: This function will panic if id is empty. This is intentional as it indicates a programming error in the calling code. This constructor is used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: id - unique graph identifier, must not be empty. limiter - rate limiter for execution throttling. Returns new graph instance.
func NewGraphWithTracer ¶
func NewGraphWithTracer(id string, tracer observability.Tracer) *Graph
NewGraphWithTracer creates a new graph with a custom tracer.
NOTE: This function will panic if id is empty or tracer is nil. This is intentional as it indicates a programming error in the calling code. This constructor is used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: id - unique graph identifier, must not be empty. tracer - observability tracer, must not be nil. Returns new graph instance.
func (*Graph) Edge ¶
Edge adds an edge from one node to another with optional condition.
NOTE: This method will panic if graph is nil, from id is empty, or to id is empty. This is intentional as it indicates a programming error in the calling code. These methods are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: from - source node ID, must not be empty. to - target node ID, must not be empty. cond - optional edge traversal condition. Returns graph for method chaining.
func (*Graph) Node ¶
Node adds a node to the graph.
NOTE: This method will panic if graph is nil, id is empty, or node is nil. This is intentional as it indicates a programming error in the calling code. These methods are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: id - unique node identifier, must not be empty. node - node instance, must not be nil. Returns graph for method chaining.
func (*Graph) SetLimiter ¶
SetLimiter sets a custom rate limiter for the graph.
NOTE: This method will panic if graph is nil. This is intentional as it indicates a programming error in the calling code. These methods are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: limiter - custom rate limiter instance (can be nil for no limiting). Returns graph for method chaining.
func (*Graph) SetScheduler ¶
SetScheduler sets a custom scheduler for the graph.
NOTE: This method will panic if graph is nil or scheduler is nil. This is intentional as it indicates a programming error in the calling code. These methods are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: scheduler - custom scheduler instance, must not be nil. Returns graph for method chaining.
func (*Graph) SetTracer ¶
func (g *Graph) SetTracer(tracer observability.Tracer) *Graph
SetTracer sets a custom tracer for the graph.
NOTE: This method will panic if graph is nil or tracer is nil. This is intentional as it indicates a programming error in the calling code. These methods are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: tracer - custom tracer instance, must not be nil. Returns graph for method chaining.
func (*Graph) Start ¶
Start sets the starting node for the graph.
NOTE: This method will panic if graph is nil or id is empty. This is intentional as it indicates a programming error in the calling code. These methods are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: id - starting node ID, must not be empty. Returns graph for method chaining.
type Node ¶
type Node interface {
// Execute runs the node with the given state.
Execute(ctx context.Context, state *State) error
// ID returns the unique identifier of the node.
ID() string
}
Node represents an executable unit in the graph.
type PriorityScheduler ¶
type PriorityScheduler struct {
// contains filtered or unexported fields
}
PriorityScheduler provides priority-based scheduling.
func NewPriorityScheduler ¶
func NewPriorityScheduler(priorities map[string]int) *PriorityScheduler
NewPriorityScheduler creates a new priority scheduler.
func (*PriorityScheduler) Select ¶
func (s *PriorityScheduler) Select(ready []string) string
Select returns the ready node with the highest priority.
type Scheduler ¶
type Scheduler interface {
// Select returns the next node ID to execute from the ready queue.
Select(ready []string) string
}
Scheduler defines the interface for node scheduling.
type ShortJobScheduler ¶
type ShortJobScheduler struct {
// contains filtered or unexported fields
}
ShortJobScheduler provides shortest-job-first scheduling.
func NewShortJobScheduler ¶
func NewShortJobScheduler(estimates map[string]int) *ShortJobScheduler
NewShortJobScheduler creates a new short-job scheduler.
func (*ShortJobScheduler) Select ¶
func (s *ShortJobScheduler) Select(ready []string) string
Select returns the ready node with the shortest estimated execution time.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the shared runtime state for graph execution. It is lock-free as graph execution is single-threaded by default.
func (*State) Get ¶
Get retrieves a value from the state by key. Returns the value and a boolean indicating whether the key exists.
type ToolNode ¶
type ToolNode struct {
// contains filtered or unexported fields
}
ToolNode wraps an existing tool to be used as a node.
func NewToolNode ¶
NewToolNode creates a new tool node.
NOTE: This function will panic if tool is nil. This is intentional as it indicates a programming error in the calling code. These constructors are used during workflow graph initialization (startup phase), and invalid parameters represent fatal startup failures that should prevent application launch. This follows the coding standard allowing panic for fatal startup errors.
Args: tool - tool instance, must not be nil. Returns new tool node.