(id: number)
| 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(() => { |
no test coverage detected