refactor: clean code

This commit is contained in:
Fu Diwei
2025-02-06 23:11:16 +08:00
parent 3f9fda8a2d
commit 886f166e66
22 changed files with 311 additions and 194 deletions

View File

@@ -31,7 +31,7 @@ func NewApplyNode(node *domain.WorkflowNode) *applyNode {
}
}
func (n *applyNode) Run(ctx context.Context) error {
func (n *applyNode) Process(ctx context.Context) error {
n.AddOutput(ctx, n.node.Name, "开始执行")
// 查询上次执行结果

View File

@@ -18,7 +18,7 @@ func NewConditionNode(node *domain.WorkflowNode) *conditionNode {
}
}
func (n *conditionNode) Run(ctx context.Context) error {
func (n *conditionNode) Process(ctx context.Context) error {
// 此类型节点不需要执行任何操作,直接返回
n.AddOutput(ctx, n.node.Name, "完成")

View File

@@ -29,7 +29,7 @@ func NewDeployNode(node *domain.WorkflowNode) *deployNode {
}
}
func (n *deployNode) Run(ctx context.Context) error {
func (n *deployNode) Process(ctx context.Context) error {
n.AddOutput(ctx, n.node.Name, "开始执行")
// 查询上次执行结果

View File

@@ -18,7 +18,7 @@ func NewExecuteFailureNode(node *domain.WorkflowNode) *executeFailureNode {
}
}
func (n *executeFailureNode) Run(ctx context.Context) error {
func (n *executeFailureNode) Process(ctx context.Context) error {
// 此类型节点不需要执行任何操作,直接返回
n.AddOutput(ctx, n.node.Name, "进入执行失败分支")

View File

@@ -18,7 +18,7 @@ func NewExecuteSuccessNode(node *domain.WorkflowNode) *executeSuccessNode {
}
}
func (n *executeSuccessNode) Run(ctx context.Context) error {
func (n *executeSuccessNode) Process(ctx context.Context) error {
// 此类型节点不需要执行任何操作,直接返回
n.AddOutput(ctx, n.node.Name, "进入执行成功分支")

View File

@@ -24,7 +24,7 @@ func NewNotifyNode(node *domain.WorkflowNode) *notifyNode {
}
}
func (n *notifyNode) Run(ctx context.Context) error {
func (n *notifyNode) Process(ctx context.Context) error {
n.AddOutput(ctx, n.node.Name, "开始执行")
nodeConfig := n.node.GetConfigForNotify()

View File

@@ -9,7 +9,7 @@ import (
)
type NodeProcessor interface {
Run(ctx context.Context) error
Process(ctx context.Context) error
GetLog(ctx context.Context) *domain.WorkflowRunLog
AddOutput(ctx context.Context, title, content string, err ...string)
}

View File

@@ -18,7 +18,7 @@ func NewStartNode(node *domain.WorkflowNode) *startNode {
}
}
func (n *startNode) Run(ctx context.Context) error {
func (n *startNode) Process(ctx context.Context) error {
// 此类型节点不需要执行任何操作,直接返回
n.AddOutput(ctx, n.node.Name, "完成")

View File

@@ -29,9 +29,7 @@ func NewUploadNode(node *domain.WorkflowNode) *uploadNode {
}
}
// Run 上传证书节点执行
// 包含上传证书的工作流,理论上应该手动执行,如果每天定时执行,也只是重新保存一下
func (n *uploadNode) Run(ctx context.Context) error {
func (n *uploadNode) Process(ctx context.Context) error {
n.AddOutput(ctx, n.node.Name, "进入上传证书节点")
nodeConfig := n.node.GetConfigForUpload()