MCPcopy Create free account
hub / github.com/Effect-TS/effect / wrapConnection

Function wrapConnection

packages/cluster/test/SqlRunnerStorage.test.ts:180–206  ·  view source on GitHub ↗
(connection: SqlConnection.Connection)

Source from the content-addressed store, hash-verified

178 Effect.gen(function*() {
179 const sql = yield* SqlClient.SqlClient
180 const wrapConnection = (connection: SqlConnection.Connection): SqlConnection.Connection => {
181 const execute = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
182 Effect.suspend(() => {
183 partition.activeQueries++
184 return Effect.suspend(function waitForConnection(): Effect.Effect<A, E, R> {
185 return partition.current
186 ? Effect.andThen(Effect.sleep(5), waitForConnection)
187 : effect
188 }).pipe(
189 Effect.onExit((exit) =>
190 Effect.sync(() => {
191 partition.activeQueries--
192 if (Exit.isFailure(exit) && Exit.isInterrupted(exit)) {
193 partition.interruptedQueries++
194 }
195 })
196 )
197 )
198 })
199 return {
200 ...connection,
201 execute: (...args) => execute(connection.execute(...args)),
202 executeRaw: (...args) => execute(connection.executeRaw(...args)),
203 executeValues: (...args) => execute(connection.executeValues(...args)),
204 executeUnprepared: (...args) => execute(connection.executeUnprepared(...args))
205 }
206 }
207 const client: SqlClient.SqlClient = new Proxy(sql, {
208 get(target, property, receiver) {
209 if (property === "reserve") {

Callers 1

getFunction · 0.85

Calls 5

executeFunction · 0.70
executeMethod · 0.45
executeRawMethod · 0.45
executeValuesMethod · 0.45
executeUnpreparedMethod · 0.45

Tested by

no test coverage detected