Browse Source

set params in context

EUGENIO SOUZA CARVALHO 4 years ago
parent
commit
1d38f38230
2 changed files with 10 additions and 8 deletions
  1. 1 1
      api/sse/hub.go
  2. 9 7
      api/utils.go

+ 1 - 1
api/sse/hub.go

@@ -251,7 +251,7 @@ reset:
 				}	
 			}()
 		case <-hub.consume:
-			ctx.Application().Logger().Warnf("init.notification.loop 5s")
+			// ctx.Application().Logger().Warnf("init.notification.loop 5s")
 			if count, redisErr = redis.Int(conn.Do("LLEN", channelId)); count == 0 || redisErr != nil {
 				continue reset
 			}

+ 9 - 7
api/utils.go

@@ -437,7 +437,16 @@ func transactionHandler(ctx context.Context, action string) (err *errs.Error) {
 	case "commit":
 		operation = func() error { return contextSession.CommitTransaction(contextSession) }
 	}
+	
+	defer func ()  {
+		if localErr != nil {
+			err = errs.Internal().Details(&errs.Detail{
+				Message: localErr.Error(),
+			})
+		}
+	}()
 	try := 4
+	
 	for {
 		if localErr = operation(); localErr == nil {
 			fmt.Println(action, "executed ")
@@ -459,13 +468,6 @@ func transactionHandler(ctx context.Context, action string) (err *errs.Error) {
 			}
 		}
 	}
-
-	if localErr != nil {
-		err = errs.Internal().Details(&errs.Detail{
-			Message: localErr.Error(),
-		})
-	}
-	return
 }
 
 func ReadJson(ctx context.Context, entity interface{}) (err *errs.Error) {