engine

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BizApplyKeySourceAuto   = "auto"
	BizApplyKeySourceReuse  = "reuse"
	BizApplyKeySourceCustom = "custom"
)
View Source
const (
	BizUploadSourceForm  = "form"
	BizUploadSourceLocal = "local"
	BizUploadSourceURL   = "url"
)
View Source
const (
	NodeTypeStart       = domain.WorkflowNodeTypeStart
	NodeTypeEnd         = domain.WorkflowNodeTypeEnd
	NodeTypeCondition   = domain.WorkflowNodeTypeCondition
	NodeTypeBranchBlock = domain.WorkflowNodeTypeBranchBlock
	NodeTypeTryCatch    = domain.WorkflowNodeTypeTryCatch
	NodeTypeTryBlock    = domain.WorkflowNodeTypeTryBlock
	NodeTypeCatchBlock  = domain.WorkflowNodeTypeCatchBlock
	NodeTypeDelay       = domain.WorkflowNodeTypeDelay
	NodeTypeBizApply    = domain.WorkflowNodeTypeBizApply
	NodeTypeBizUpload   = domain.WorkflowNodeTypeBizUpload
	NodeTypeBizMonitor  = domain.WorkflowNodeTypeBizMonitor
	NodeTypeBizDeploy   = domain.WorkflowNodeTypeBizDeploy
	NodeTypeBizNotify   = domain.WorkflowNodeTypeBizNotify
)

Variables

View Source
var (
	// 表示工作流引擎执行被中断,可能已结束
	ErrTerminated = errors.New("workflow engine: execution was terminated")
	// 表示工作流引擎在执行子节点时发生异常
	ErrBlocksException = errors.New("workflow engine: error occurred when executing blocks")
)

Functions

This section is empty.

Types

type Graph

type Graph = domain.WorkflowGraph

type InOutManager

type InOutManager interface {
	All() []InOutState
	Erase()

	Add(state InOutState)
	Set(nodeId string, stype string, name string, value any, valueType string, persistent bool)
	Get(nodeId string, name string) (*InOutState, bool)
	Take(nodeId string, name string) (*InOutState, bool)
	Remove(nodeId string, name string) bool
}

type InOutState

type InOutState struct {
	NodeId     string
	Type       string
	Name       string
	Value      any
	ValueType  string
	Persistent bool
}

func (InOutState) ValueString

func (s InOutState) ValueString() string

type Node

type Node = domain.WorkflowNode

type NodeExecutionContext

type NodeExecutionContext struct {
	WorkflowContext

	Node *Node
}

func (*NodeExecutionContext) SetContext

func (*NodeExecutionContext) SetEngine

func (*NodeExecutionContext) SetExecutingNode

func (c *NodeExecutionContext) SetExecutingNode(node *Node) *NodeExecutionContext

func (*NodeExecutionContext) SetExecutingWorkflow

func (c *NodeExecutionContext) SetExecutingWorkflow(workflowId string, runId string, runGraph *Graph) *NodeExecutionContext

func (*NodeExecutionContext) SetInputsManager

func (c *NodeExecutionContext) SetInputsManager(inputs InOutManager) *NodeExecutionContext

func (*NodeExecutionContext) SetVariablesManager

func (c *NodeExecutionContext) SetVariablesManager(variables VariableManager) *NodeExecutionContext

type NodeExecutionResult

type NodeExecutionResult struct {
	Terminated bool // 是否终止执行(通常由 End 节点主动触发)

	Variables []VariableState

	Outputs []InOutState
	// contains filtered or unexported fields
}

func (*NodeExecutionResult) AddOutput

func (r *NodeExecutionResult) AddOutput(stype string, key string, value any, valueType string)

func (*NodeExecutionResult) AddOutputWithPersistent

func (r *NodeExecutionResult) AddOutputWithPersistent(stype string, key string, value any, valueType string)

func (*NodeExecutionResult) AddVariable

func (r *NodeExecutionResult) AddVariable(key string, value any, valueType string)

func (*NodeExecutionResult) AddVariableWithScope

func (r *NodeExecutionResult) AddVariableWithScope(scope string, key string, value any, valueType string)

type NodeExecutor

type NodeExecutor interface {
	Execute(execCtx *NodeExecutionContext) (*NodeExecutionResult, error)
	// contains filtered or unexported methods
}

type NodeType

type NodeType = domain.WorkflowNodeType

type VariableManager

type VariableManager interface {
	All() []VariableState
	Erase()

	Add(entry VariableState)
	Set(name string, value any, valueType string)
	SetScoped(scope string, name string, value any, valueType string)
	Get(name string) (*VariableState, bool)
	GetScoped(scope string, key string) (*VariableState, bool)
	Take(key string) (*VariableState, bool)
	TakeScoped(scope string, key string) (*VariableState, bool)
	Remove(key string) bool
	RemoveScoped(scope string, key string) bool
}

type VariableState

type VariableState struct {
	Scope     string // 零值时表示全局的,否则表示指定节点的
	Key       string
	Value     any
	ValueType string
}

func (VariableState) ValueString

func (s VariableState) ValueString() string

type WorkflowContext

type WorkflowContext struct {
	WorkflowId string
	RunId      string
	RunGraph   *Graph
	// contains filtered or unexported fields
}

func (*WorkflowContext) Clone

func (c *WorkflowContext) Clone() *WorkflowContext

func (*WorkflowContext) SetContext

func (c *WorkflowContext) SetContext(ctx context.Context) *WorkflowContext

func (*WorkflowContext) SetEngine

func (c *WorkflowContext) SetEngine(engine WorkflowEngine) *WorkflowContext

func (*WorkflowContext) SetExecutingWorkflow

func (c *WorkflowContext) SetExecutingWorkflow(workflowId string, runId string, runGraph *Graph) *WorkflowContext

func (*WorkflowContext) SetInputsManager

func (c *WorkflowContext) SetInputsManager(manager InOutManager) *WorkflowContext

func (*WorkflowContext) SetVariablesManager

func (c *WorkflowContext) SetVariablesManager(inputs VariableManager) *WorkflowContext

type WorkflowEngine

type WorkflowEngine interface {
	Invoke(ctx context.Context, execution WorkflowExecution) error

	OnStart(callback func(ctx context.Context) error)
	OnEnd(callback func(ctx context.Context) error)
	OnError(callback func(ctx context.Context, err error) error)
	OnNodeStart(callback func(ctx context.Context, node *Node) error)
	OnNodeEnd(callback func(ctx context.Context, node *Node, res *NodeExecutionResult) error)
	OnNodeError(callback func(ctx context.Context, node *Node, err error) error)
	OnNodeLogging(callback func(ctx context.Context, node *Node, log logging.Record) error)
}

func NewWorkflowEngine

func NewWorkflowEngine() WorkflowEngine

type WorkflowExecution

type WorkflowExecution struct {
	WorkflowId   string
	WorkflowName string
	RunId        string
	RunTrigger   domain.WorkflowTriggerType
	Graph        *Graph
}

Jump to

Keyboard shortcuts

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