mirror of
https://github.com/usual2970/certimate.git
synced 2025-09-21 15:36:01 +00:00
27
internal/workflow/node-processor/execute_failure_node.go
Normal file
27
internal/workflow/node-processor/execute_failure_node.go
Normal 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
|
||||
}
|
27
internal/workflow/node-processor/execute_success_node.go
Normal file
27
internal/workflow/node-processor/execute_success_node.go
Normal 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
|
||||
}
|
@@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user