refactor: assemble main transaction session in MainTx
This change makes the API surface between MainTx and App smaller. Currently, App reconstructs a database transaction by unpacking the isolation level, transaction mode, DbHandler, and transaction runner returned by MainTx. That exposes MainTx internals at the call site even though MainTx already owns query setup, execution, decoding, and rollback behavior. The goal is to keep transaction assembly in MainTx while App remains responsible for pool execution, database error mapping, and response orchestration. DbTx now carries the assembled SQL session, and App passes that session directly to the connection pool.
This commit is contained in:
committed by
Steve Chavez
parent
56ad5a9324
commit
0df56f9ea8
@@ -196,8 +196,8 @@ postgrestResponse appState conf@AppConfig{..} maybeSchemaCache jwtTime authResul
|
||||
(txTime, txResult) <- withTiming conf $ do
|
||||
case tx of
|
||||
MainTx.NoDbTx r -> pure r
|
||||
MainTx.DbTx{..} -> do
|
||||
dbRes <- lift $ AppState.usePool appState (dqTransaction dqIsoLevel dqTxMode $ runExceptT dqDbHandler)
|
||||
MainTx.DbTx dbSession -> do
|
||||
dbRes <- lift $ AppState.usePool appState dbSession
|
||||
let eitherResp = join $ mapLeft (Error.PgErr . Error.PgError (Just authRole /= configDbAnonRole)) dbRes
|
||||
|
||||
-- TODO: we use obsQuery twice, one here and one below because in case of an error with the usePool above, the request will finish here and return an error message.
|
||||
|
||||
Reference in New Issue
Block a user