( fiber: Fiber.Fiber<unknown, unknown>, span: Tracer.Span, acquirer: Acquirer, borrower: Borrower | undefined, f: (connection: Connection) => Effect.Effect<XA, E> )
| 1644 | * driver spans are parented under it. |
| 1645 | */ |
| 1646 | const runOnConnection = <XA, E>( |
| 1647 | fiber: Fiber.Fiber<unknown, unknown>, |
| 1648 | span: Tracer.Span, |
| 1649 | acquirer: Acquirer, |
| 1650 | borrower: Borrower | undefined, |
| 1651 | f: (connection: Connection) => Effect.Effect<XA, E> |
| 1652 | ): Effect.Effect<XA, E | SqlError> => { |
| 1653 | const propagate = fiber.cache.tracerEnabled && fiber.getRef(SpanPropagationEnabled) |
| 1654 | // Measured from the span's start, so the wait also covers compiling the |
| 1655 | // statement and any `CurrentTransformer` run first. |
| 1656 | const clock = propagate ? waitClock(fiber) : undefined |
| 1657 | const run = clock === undefined ? f : (connection: Connection) => |
| 1658 | Effect.suspend(() => { |
| 1659 | recordConnectionWait(span, clock) |
| 1660 | return f(connection) |
| 1661 | }) |
| 1662 | const execute = borrower === undefined ? Effect.scoped(Effect.flatMap(acquirer, run)) : borrower(run) |
| 1663 | return propagate ? Effect.provideService(execute, Tracer.ParentSpan, span) : execute |
| 1664 | } |
| 1665 | |
| 1666 | const applyTransformer = <A>( |
| 1667 | self: StatementImpl<A>, |
no test coverage detected