Skip to content

Commit

Permalink
goroutine for handleTransactions - #101
Browse files Browse the repository at this point in the history
  • Loading branch information
TanmoySG committed Apr 22, 2023
1 parent c11fbc3 commit 70ad369
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 64 deletions.
15 changes: 3 additions & 12 deletions internal/server/handlers/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ func (wh wdbHandlers) CreateCollection(c *fiber.Ctx) error {
return err
}

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}

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

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}

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

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}

go wh.handleTransactions(c, resp, entities)
return nil
}
19 changes: 4 additions & 15 deletions internal/server/handlers/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ func (wh wdbHandlers) AddData(c *fiber.Ctx) error {
return err
}

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}

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

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}
go wh.handleTransactions(c, resp, entities)

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}

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

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}
go wh.handleTransactions(c, resp, entities)

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}
go wh.handleTransactions(c, resp, entities)

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}

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

if err := wh.handleTransactions(c, resp, noEntities); err != nil {
return err
}

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

if err := wh.handleTransactions(c, resp, noEntities); err != nil {
return err
}

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

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

if err := wh.handleTransactions(c, resp, noEntities); err != nil {
return err
}

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

if err := wh.handleTransactions(c, resp, noEntities); err != nil {
return err
}
go wh.handleTransactions(c, resp, noEntities)

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

if err := wh.handleTransactions(c, resp, noEntities); err != nil {
return err
}

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

Expand Down Expand Up @@ -108,10 +103,7 @@ func (wh wdbHandlers) GrantRoles(c *fiber.Ctx) error {
return err
}

if err := wh.handleTransactions(c, resp, noEntities); err != nil {
return err
}

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

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

if err := wh.handleTransactions(c, resp, entities); err != nil {
return err
}

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

0 comments on commit 70ad369

Please sign in to comment.