Files
query-orchestration/internal/serviceconfig/database/transaction.go
T
Jay Brown 15adaebfcd Merged in feature/serviceconfig-integration (pull request #38)
DRAFT PR : WIP working through ideas for integration

* movearound

* attempttwo

* openapi

* further sanding

* fix

* start on tests

* runthroughsingleconfig

* somechanges

* reflectissue

* removeerrs

* mostlyremovepanic

* removeenv

* noncfgtests

* go

* repo

* fix service config test

* add PWD to all

* test fix

* fix lint

* todo for later

* passingunittests

* alltests

* testlogger

* testloggername

* clean
2025-01-31 13:43:55 +00:00

31 lines
506 B
Go

package database
import (
"context"
"queryorchestration/internal/database/repository"
)
func (b *BaseConfig) ExecuteDBTransaction(ctx context.Context, executeQueries func(context.Context, *repository.Queries) error) error {
tx, err := b.DBPool.Begin(ctx)
if err != nil {
return err
}
defer func() {
_ = tx.Rollback(ctx)
}()
qtx := b.DBQueries.WithTx(tx)
err = executeQueries(ctx, qtx)
if err != nil {
return err
}
err = tx.Commit(ctx)
if err != nil {
return err
}
return nil
}