Skip to content

Commit

Permalink
Revert Async txn logging [Revert #103] #104
Browse files Browse the repository at this point in the history
  • Loading branch information
TanmoySG authored Apr 23, 2023
2 parents f69590e + ea65915 commit 5db33a2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
6 changes: 3 additions & 3 deletions internal/server/handlers/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (wh wdbHandlers) CreateCollection(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)
return nil
}

Expand Down Expand Up @@ -78,7 +78,7 @@ func (wh wdbHandlers) FetchCollection(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)
return nil
}

Expand Down Expand Up @@ -108,6 +108,6 @@ func (wh wdbHandlers) DeleteCollection(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)
return nil
}
14 changes: 8 additions & 6 deletions internal/server/handlers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func validateRequest(request any) *er.WdbError {
}

func (wh wdbHandlers) handleTransactions(c *fiber.Ctx, apiResponse response.ApiResponse, entities model.Entities) {
var err error
if txlogs.IsTxnLoggable(apiResponse.Response.Action) {
if apiResponse.Response.Status == response.StatusSuccess {
databaseEntity := *entities.Databases
Expand All @@ -117,12 +116,15 @@ func (wh wdbHandlers) handleTransactions(c *fiber.Ctx, apiResponse response.ApiR
}

txnLog := txlogs.CreateTxLog(txnAction, txnActor, apiResponse.Response.Status, txnEntityPath, txnHttpDetails)
err = wh.wdbTxLogs.Log(txnLog)
err := wh.wdbTxLogs.Log(txnLog)
if err != nil {
log.Errorf("error logging transaction: %s", err)
}

err = wh.wdbTxLogs.Commit()

if err != nil {
log.Errorf("error logging transaction: %s", err)
}
}
}
if err != nil {
log.Errorf("error logging transaction: %s", err)
}
}
8 changes: 4 additions & 4 deletions internal/server/handlers/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (wh wdbHandlers) AddData(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)
return nil
}

Expand Down Expand Up @@ -85,7 +85,7 @@ func (wh wdbHandlers) ReadData(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)

return nil
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (wh wdbHandlers) DeleteData(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)
return nil
}

Expand Down Expand Up @@ -175,6 +175,6 @@ func (wh wdbHandlers) UpdateData(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)
return nil
}
6 changes: 3 additions & 3 deletions internal/server/handlers/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (wh wdbHandlers) CreateDatabase(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)

return nil
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func (wh wdbHandlers) FetchDatabase(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)

return nil
}
Expand Down Expand Up @@ -98,6 +98,6 @@ func (wh wdbHandlers) DeleteDatabase(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, entities)
wh.handleTransactions(c, resp, entities)
return nil
}
2 changes: 1 addition & 1 deletion internal/server/handlers/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ func (wh wdbHandlers) Hello(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, noEntities)
wh.handleTransactions(c, resp, noEntities)
return nil
}
4 changes: 2 additions & 2 deletions internal/server/handlers/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (wh wdbHandlers) CreateRole(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, noEntities)
wh.handleTransactions(c, resp, noEntities)
return nil
}

Expand All @@ -65,6 +65,6 @@ func (wh wdbHandlers) ListRoles(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, noEntities)
wh.handleTransactions(c, resp, noEntities)
return nil
}
6 changes: 3 additions & 3 deletions internal/server/handlers/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (wh wdbHandlers) LoginUser(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, noEntities)
wh.handleTransactions(c, resp, noEntities)

return nil
}
Expand All @@ -63,7 +63,7 @@ func (wh wdbHandlers) CreateUser(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, noEntities)
wh.handleTransactions(c, resp, noEntities)
return nil
}

Expand Down Expand Up @@ -128,6 +128,6 @@ func (wh wdbHandlers) CheckPermissions(c *fiber.Ctx) error {
return err
}

go wh.handleTransactions(c, resp, noEntities)
wh.handleTransactions(c, resp, noEntities)
return nil
}

0 comments on commit 5db33a2

Please sign in to comment.