(transactionService: Context.Key<any, any>)
| 652 | |
| 653 | const makeAfterCommit = |
| 654 | (transactionService: Context.Key<any, any>) => |
| 655 | <R>(effect: Effect.Effect<void, never, R>): Effect.Effect<void, never, R> => |
| 656 | Effect.withFiber((fiber) => { |
| 657 | const transaction = Context.getOrUndefined(fiber.context, transactionService) |
| 658 | const buffer = transaction && afterCommitBuffers.get(transaction) |
| 659 | // Outside a transaction, or in one that doesn't buffer callbacks. |
| 660 | if (buffer === undefined) { |
| 661 | return runAfterCommit(effect) |
| 662 | } |
| 663 | if (hasEnded(buffer)) { |
| 664 | return Effect.die(new Error("SqlClient.afterCommit: the transaction has already ended")) |
| 665 | } |
| 666 | // Runs later with the services in scope now, without the transaction. |
| 667 | buffer.callbacks.push( |
| 668 | Effect.provideContext(effect, Context.omit(transactionService)(fiber.context) as Context.Context<R>) |
| 669 | ) |
| 670 | return Effect.void |
| 671 | }) |
| 672 | |
| 673 | /** |
| 674 | * Builds a transaction wrapper that begins top-level transactions, uses |
no test coverage detected