You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2022/10/27 02:51:19 UTC

[incubator-eventmesh] branch master updated: remove gorm log

This is an automated email from the ASF dual-hosted git repository.

mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new 613a0110 remove gorm log
     new b472ecaa Merge pull request #1938 from walterlife/optimize-dal-logic
613a0110 is described below

commit 613a01109b2724ec6f464e8e3c4cbfb186730f2f
Author: yuweizhu <yu...@tencent.com>
AuthorDate: Wed Oct 26 23:35:41 2022 +0800

    remove gorm log
---
 eventmesh-workflow-go/internal/dal/config.go   |  2 +-
 eventmesh-workflow-go/internal/dal/workflow.go | 17 +++++++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/eventmesh-workflow-go/internal/dal/config.go b/eventmesh-workflow-go/internal/dal/config.go
index 3bf1d44a..bc00cce6 100644
--- a/eventmesh-workflow-go/internal/dal/config.go
+++ b/eventmesh-workflow-go/internal/dal/config.go
@@ -38,7 +38,7 @@ func Open() error {
 	d.SetConnMaxLifetime(time.Millisecond * time.Duration(pmysql.PluginConfig.MaxLifetime))
 
 	workflowDB, err = gorm.Open(mysql.New(mysql.Config{Conn: d}),
-		&gorm.Config{Logger: logger.Default.LogMode(logger.Info)})
+		&gorm.Config{Logger: logger.Default.LogMode(logger.Silent)})
 	if err != nil {
 		return err
 	}
diff --git a/eventmesh-workflow-go/internal/dal/workflow.go b/eventmesh-workflow-go/internal/dal/workflow.go
index 1622973b..04322618 100644
--- a/eventmesh-workflow-go/internal/dal/workflow.go
+++ b/eventmesh-workflow-go/internal/dal/workflow.go
@@ -38,6 +38,7 @@ type WorkflowDAL interface {
 	Insert(ctx context.Context, record *model.Workflow) error
 	InsertInstance(ctx context.Context, record *model.WorkflowInstance) error
 	InsertTaskInstance(ctx context.Context, record *model.WorkflowTaskInstance) error
+	UpdateInstance(ctx context.Context, record *model.WorkflowInstance) error
 	UpdateTaskInstance(tx *gorm.DB, record *model.WorkflowTaskInstance) error
 }
 
@@ -104,15 +105,15 @@ func (w *workflowDALImpl) SelectTaskInstance(ctx context.Context, condition mode
 	var childTasks []*model.WorkflowTaskRelation
 	var taskActions []*model.WorkflowTaskAction
 	handlers = append(handlers, func() error {
-		tasks, err = w.selectTask(context.Background(), condition.WorkflowID, []string{r.TaskID})
+		tasks, err = w.selectTask(context.Background(), r.WorkflowID, []string{r.TaskID})
 		return err
 	})
 	handlers = append(handlers, func() error {
-		childTasks, err = w.selectTaskRelation(context.Background(), condition.WorkflowID, condition.TaskID)
+		childTasks, err = w.selectTaskRelation(context.Background(), r.WorkflowID, r.TaskID)
 		return err
 	})
 	handlers = append(handlers, func() error {
-		taskActions, err = w.selectTaskAction(context.Background(), condition.WorkflowID, []string{r.TaskID})
+		taskActions, err = w.selectTaskAction(context.Background(), r.WorkflowID, []string{r.TaskID})
 		if err != nil {
 			return err
 		}
@@ -171,8 +172,15 @@ func (w *workflowDALImpl) InsertTaskInstance(ctx context.Context,
 	return workflowDB.WithContext(ctx).Create(&record).Error
 }
 
+func (w *workflowDALImpl) UpdateInstance(ctx context.Context, record *model.WorkflowInstance) error {
+	var condition = model.WorkflowInstance{WorkflowInstanceID: record.WorkflowInstanceID}
+	record.UpdateTime = time.Now()
+	return workflowDB.WithContext(ctx).Where(&condition).Updates(&record).Error
+}
+
 func (w *workflowDALImpl) UpdateTaskInstance(tx *gorm.DB, record *model.WorkflowTaskInstance) error {
-	var condition = model.WorkflowInstance{ID: record.ID}
+	var condition = model.WorkflowTaskInstance{ID: record.ID}
+	record.UpdateTime = time.Now()
 	return tx.Where(&condition).Updates(&record).Error
 }
 
@@ -228,6 +236,7 @@ func (w *workflowDALImpl) buildTaskRelation(workflow *pmodel.Workflow,
 		}
 		switch state.GetType() {
 		case pmodel.StateTypeOperation:
+			fallthrough
 		case pmodel.StateTypeEvent:
 			taskRelations = append(taskRelations, w.doBuildTaskRelation(workflow, state, taskIDs))
 		case pmodel.StateTypeSwitch:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org