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

Function open

packages/sql/sqlite-do/src/SqliteClient.ts:143–160  ·  view source on GitHub ↗
(id: number)

Source from the content-addressed store, hash-verified

141
142 // Parks the storage callback so the body runs on the fiber.
143 const open = (id: number) =>
144 Effect.callback<void, SqlError>((resume) => {
145 const done: Promise<Exit.Exit<void, SqlError>> = storage.transaction((txn) =>
146 new Promise<void>((resolve) => {
147 resume(Effect.sync(() => {
148 levels[id] = { txn, resolve, done }
149 }))
150 })
151 ).then(
152 () => Exit.void,
153 (cause) => {
154 const exit = Exit.fail(new SqlError({ reason: classifyError(cause, "Failed transaction", "transaction") }))
155 // Only takes effect if storage rejects before the callback starts.
156 resume(exit)
157 return exit
158 }
159 )
160 })
161
162 const close = (id: number) =>
163 Effect.suspend(() => {

Callers 2

makeFunction · 0.50

Calls 5

classifyErrorFunction · 0.70
failMethod · 0.65
resumeFunction · 0.50
transactionMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected