MCPcopy Create free account
hub / github.com/astercloud/aster / evaluateCondition

Method evaluateCondition

pkg/workflow/engine.go:821–848  ·  view source on GitHub ↗

evaluateCondition 评估条件

(execution *WorkflowExecution, condition *ConditionDef)

Source from the content-addressed store, hash-verified

819
820// evaluateCondition 评估条件
821func (e *Engine) evaluateCondition(execution *WorkflowExecution, condition *ConditionDef) (bool, error) {
822 evaluator := NewExpressionEvaluator(execution.Context.Variables)
823
824 switch condition.Type {
825 case ConditionTypeAnd:
826 for _, rule := range condition.Rules {
827 if result, err := e.evaluateConditionRule(execution, rule, evaluator); err != nil {
828 return false, err
829 } else if !result {
830 return false, nil
831 }
832 }
833 return true, nil
834 case ConditionTypeOr:
835 for _, rule := range condition.Rules {
836 if result, err := e.evaluateConditionRule(execution, rule, evaluator); err != nil {
837 return false, err
838 } else if result {
839 return true, nil
840 }
841 }
842 return false, nil
843 case ConditionTypeCustom:
844 return evaluator.EvaluateBool(condition.Custom)
845 default:
846 return false, fmt.Errorf("unsupported condition type: %s", condition.Type)
847 }
848}
849
850// evaluateConditionRule 评估条件规则
851func (e *Engine) evaluateConditionRule(execution *WorkflowExecution, rule ConditionRule, evaluator *ExpressionEvaluator) (bool, error) {

Callers 1

executeConditionNodeMethod · 0.95

Calls 3

evaluateConditionRuleMethod · 0.95
EvaluateBoolMethod · 0.95
NewExpressionEvaluatorFunction · 0.85

Tested by

no test coverage detected