feat: rename workflow_run_log to workflow_run
This commit is contained in:
@@ -10,30 +10,30 @@ import (
|
||||
|
||||
type NodeProcessor interface {
|
||||
Run(ctx context.Context) error
|
||||
Log(ctx context.Context) *domain.RunLog
|
||||
Log(ctx context.Context) *domain.WorkflowRunLog
|
||||
AddOutput(ctx context.Context, title, content string, err ...string)
|
||||
}
|
||||
|
||||
type Logger struct {
|
||||
log *domain.RunLog
|
||||
log *domain.WorkflowRunLog
|
||||
}
|
||||
|
||||
func NewLogger(node *domain.WorkflowNode) *Logger {
|
||||
return &Logger{
|
||||
log: &domain.RunLog{
|
||||
log: &domain.WorkflowRunLog{
|
||||
NodeId: node.Id,
|
||||
NodeName: node.Name,
|
||||
Outputs: make([]domain.RunLogOutput, 0),
|
||||
Outputs: make([]domain.WorkflowRunLogOutput, 0),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Logger) Log(ctx context.Context) *domain.RunLog {
|
||||
func (l *Logger) Log(ctx context.Context) *domain.WorkflowRunLog {
|
||||
return l.log
|
||||
}
|
||||
|
||||
func (l *Logger) AddOutput(ctx context.Context, title, content string, err ...string) {
|
||||
output := domain.RunLogOutput{
|
||||
output := domain.WorkflowRunLogOutput{
|
||||
Time: time.Now().UTC().Format(time.RFC3339),
|
||||
Title: title,
|
||||
Content: content,
|
||||
|
||||
@@ -8,17 +8,17 @@ import (
|
||||
|
||||
type workflowProcessor struct {
|
||||
workflow *domain.Workflow
|
||||
logs []domain.RunLog
|
||||
logs []domain.WorkflowRunLog
|
||||
}
|
||||
|
||||
func NewWorkflowProcessor(workflow *domain.Workflow) *workflowProcessor {
|
||||
return &workflowProcessor{
|
||||
workflow: workflow,
|
||||
logs: make([]domain.RunLog, 0),
|
||||
logs: make([]domain.WorkflowRunLog, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (w *workflowProcessor) Log(ctx context.Context) []domain.RunLog {
|
||||
func (w *workflowProcessor) Log(ctx context.Context) []domain.WorkflowRunLog {
|
||||
return w.logs
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
type WorkflowRepository interface {
|
||||
Get(ctx context.Context, id string) (*domain.Workflow, error)
|
||||
SaveRunLog(ctx context.Context, log *domain.WorkflowRunLog) error
|
||||
SaveRunLog(ctx context.Context, log *domain.WorkflowRun) error
|
||||
ListEnabledAuto(ctx context.Context) ([]domain.Workflow, error)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (s *WorkflowService) Run(ctx context.Context, req *domain.WorkflowRunReq) e
|
||||
|
||||
processor := nodeprocessor.NewWorkflowProcessor(workflow)
|
||||
if err := processor.Run(ctx); err != nil {
|
||||
log := &domain.WorkflowRunLog{
|
||||
log := &domain.WorkflowRun{
|
||||
WorkflowId: workflow.Id,
|
||||
Logs: processor.Log(ctx),
|
||||
Succeeded: false,
|
||||
@@ -82,13 +82,13 @@ func (s *WorkflowService) Run(ctx context.Context, req *domain.WorkflowRunReq) e
|
||||
|
||||
// 保存执行日志
|
||||
logs := processor.Log(ctx)
|
||||
runLogs := domain.RunLogs(logs)
|
||||
runErr := runLogs.Error()
|
||||
runLogs := domain.WorkflowRunLogs(logs)
|
||||
runErr := runLogs.FirstError()
|
||||
succeed := true
|
||||
if runErr != "" {
|
||||
succeed = false
|
||||
}
|
||||
log := &domain.WorkflowRunLog{
|
||||
log := &domain.WorkflowRun{
|
||||
WorkflowId: workflow.Id,
|
||||
Logs: processor.Log(ctx),
|
||||
Error: runErr,
|
||||
|
||||
Reference in New Issue
Block a user