Pārlūkot izejas kodu

fixes typo in code

bergquist 7 gadi atpakaļ
vecāks
revīzija
6775a82c82
2 mainītis faili ar 10 papildinājumiem un 8 dzēšanām
  1. 3 3
      pkg/bus/bus.go
  2. 7 5
      pkg/services/sqlstore/sqlstore.go

+ 3 - 3
pkg/bus/bus.go

@@ -13,7 +13,7 @@ type Msg interface{}
 var ErrHandlerNotFound = errors.New("handler not found")
 
 type TransactionWrapper interface {
-	Wrapp(ctx context.Context, fn func(ctx context.Context) error) error
+	Wrap(ctx context.Context, fn func(ctx context.Context) error) error
 }
 
 type Bus interface {
@@ -39,7 +39,7 @@ type Bus interface {
 }
 
 func (b *InProcBus) InTransaction(ctx context.Context, fn func(ctx context.Context) error) error {
-	return b.transactionWrapper.Wrapp(ctx, fn)
+	return b.transactionWrapper.Wrap(ctx, fn)
 }
 
 type InProcBus struct {
@@ -213,6 +213,6 @@ func ClearBusHandlers() {
 
 type noopTransactionManager struct{}
 
-func (*noopTransactionManager) Wrapp(ctx context.Context, fn func(ctx context.Context) error) error {
+func (*noopTransactionManager) Wrap(ctx context.Context, fn func(ctx context.Context) error) error {
 	return nil
 }

+ 7 - 5
pkg/services/sqlstore/sqlstore.go

@@ -99,11 +99,11 @@ type SQLTransactionManager struct {
 	engine *xorm.Engine
 }
 
-func (stm *SQLTransactionManager) Wrapp(ctx context.Context, fn func(ctx context.Context) error) error {
-	return stm.wrappInternal(ctx, fn, 0)
+func (stm *SQLTransactionManager) Wrap(ctx context.Context, fn func(ctx context.Context) error) error {
+	return stm.wrapInternal(ctx, fn, 0)
 }
 
-func (stm *SQLTransactionManager) wrappInternal(ctx context.Context, fn func(ctx context.Context) error, retry int) error {
+func (stm *SQLTransactionManager) wrapInternal(ctx context.Context, fn func(ctx context.Context) error, retry int) error {
 	sess := startSession(ctx)
 	defer sess.Close()
 
@@ -117,14 +117,16 @@ func (stm *SQLTransactionManager) wrappInternal(ctx context.Context, fn func(ctx
 			sess.Rollback()
 			time.Sleep(time.Millisecond * time.Duration(10))
 			sqlog.Info("Database table locked, sleeping then retrying", "retry", retry)
-			return stm.wrappInternal(ctx, fn, retry+1)
+			return stm.wrapInternal(ctx, fn, retry+1)
 		}
 	}
 
 	if err != nil {
 		sess.Rollback()
 		return err
-	} else if err = sess.Commit(); err != nil {
+	}
+
+	if err = sess.Commit(); err != nil {
 		return err
 	}