refactor(backend/db): remove ctx argument from transaction wrapper
This commit is contained in:
parent
5ac528be05
commit
59eacd6bc5
@ -30,13 +30,14 @@ func InitDB(connString string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func transaction(ctx context.Context, handler func(pgx.Tx) (statusCode int, err error)) (statusCode int, err error) {
|
func transaction(handler func(context.Context, pgx.Tx) (statusCode int, err error)) (statusCode int, err error) {
|
||||||
|
ctx := context.Background()
|
||||||
tx, err := connPool.Begin(ctx)
|
tx, err := connPool.Begin(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
statusCode = http.StatusInternalServerError
|
statusCode = http.StatusInternalServerError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
statusCode, err = handler(tx)
|
statusCode, err = handler(ctx, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback(ctx)
|
tx.Rollback(ctx)
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user