refactor(backend/db): remove ctx argument from transaction wrapper

This commit is contained in:
Masahiko AMANO 2025-07-03 15:35:56 +03:00
parent 5ac528be05
commit 59eacd6bc5

View File

@ -30,13 +30,14 @@ func InitDB(connString string) error {
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)
if err != nil {
statusCode = http.StatusInternalServerError
return
}
statusCode, err = handler(tx)
statusCode, err = handler(ctx, tx)
if err != nil {
tx.Rollback(ctx)
return