Merge pull request #425 from usual2970/feat/result_branch

添加执行结果分支节点
This commit is contained in:
Yoan.liu
2025-01-20 09:46:50 +08:00
committed by GitHub
13 changed files with 342 additions and 49 deletions

View File

@@ -0,0 +1,27 @@
package nodeprocessor
import (
"context"
"github.com/usual2970/certimate/internal/domain"
)
type executeFailureNode struct {
node *domain.WorkflowNode
*nodeLogger
}
func NewExecuteFailureNode(node *domain.WorkflowNode) *executeFailureNode {
return &executeFailureNode{
node: node,
nodeLogger: NewNodeLogger(node),
}
}
func (e *executeFailureNode) Run(ctx context.Context) error {
e.AddOutput(ctx,
e.node.Name,
"进入执行失败分支",
)
return nil
}

View File

@@ -0,0 +1,27 @@
package nodeprocessor
import (
"context"
"github.com/usual2970/certimate/internal/domain"
)
type executeSuccessNode struct {
node *domain.WorkflowNode
*nodeLogger
}
func NewExecuteSuccessNode(node *domain.WorkflowNode) *executeSuccessNode {
return &executeSuccessNode{
node: node,
nodeLogger: NewNodeLogger(node),
}
}
func (e *executeSuccessNode) Run(ctx context.Context) error {
e.AddOutput(ctx,
e.node.Name,
"进入执行成功分支",
)
return nil
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/usual2970/certimate/internal/domain"
)
type nodeProcessor interface {
type NodeProcessor interface {
Run(ctx context.Context) error
Log(ctx context.Context) *domain.WorkflowRunLog
AddOutput(ctx context.Context, title, content string, err ...string)
@@ -58,7 +58,7 @@ func (l *nodeLogger) AddOutput(ctx context.Context, title, content string, err .
l.log.Outputs = append(l.log.Outputs, output)
}
func GetProcessor(node *domain.WorkflowNode) (nodeProcessor, error) {
func GetProcessor(node *domain.WorkflowNode) (NodeProcessor, error) {
switch node.Type {
case domain.WorkflowNodeTypeStart:
return NewStartNode(node), nil
@@ -70,6 +70,10 @@ func GetProcessor(node *domain.WorkflowNode) (nodeProcessor, error) {
return NewDeployNode(node), nil
case domain.WorkflowNodeTypeNotify:
return NewNotifyNode(node), nil
case domain.WorkflowNodeTypeExecuteSuccess:
return NewExecuteSuccessNode(node), nil
case domain.WorkflowNodeTypeExecuteFailure:
return NewExecuteFailureNode(node), nil
}
return nil, errors.New("not implemented")
}