-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* qe-wasm: Split query engine by connector Intoroduces separate features for mysql, postgresql and sqlite connectors and builds 3 individual engines for each. All engines are put and published as a single package (with connector-specific) engine in subdirectory. It is up to a client to pick the correct one. Contributes to prisma/team-orm#891 * feat: some of the review comments * Fix size job * Fix size again
- Loading branch information
Serhii Tatarintsev
authored
Feb 7, 2024
1 parent
893c63a
commit d771e84
Showing
23 changed files
with
249 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
import * as wasm from '../../../query-engine-wasm/pkg/query_engine_bg.js' | ||
import * as wasmPostgres from '../../../query-engine-wasm/pkg/postgresql/query_engine_bg.js' | ||
import * as wasmMysql from '../../../query-engine-wasm/pkg/mysql/query_engine_bg.js' | ||
import * as wasmSqlite from '../../../query-engine-wasm/pkg/sqlite/query_engine_bg.js' | ||
import fs from 'node:fs/promises' | ||
import path from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
|
||
const dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
const bytes = await fs.readFile(path.resolve(dirname, '..', '..', '..', 'query-engine-wasm', 'pkg', 'query_engine_bg.wasm')) | ||
const module = new WebAssembly.Module(bytes) | ||
const instance = new WebAssembly.Instance(module, { './query_engine_bg.js': wasm }) | ||
wasm.__wbg_set_wasm(instance.exports); | ||
const wasm = { | ||
postgres: wasmPostgres, | ||
mysql: wasmMysql, | ||
sqlite: wasmSqlite | ||
} | ||
|
||
export const WasmQueryEngine = wasm.QueryEngine | ||
type EngineName = keyof typeof wasm; | ||
|
||
const initializedModules = new Set<EngineName>() | ||
|
||
|
||
|
||
export async function getEngineForProvider(provider: EngineName) { | ||
const engine = wasm[provider] | ||
if (!initializedModules.has(provider)) { | ||
const subDir = provider === 'postgres' ? 'postgresql' : provider | ||
const bytes = await fs.readFile(path.resolve(dirname, '..', '..', '..', 'query-engine-wasm', 'pkg', subDir, 'query_engine_bg.wasm')) | ||
console.error(bytes) | ||
const module = new WebAssembly.Module(bytes) | ||
const instance = new WebAssembly.Instance(module, { './query_engine_bg.js': engine }) | ||
engine.__wbg_set_wasm(instance.exports); | ||
initializedModules.add(provider) | ||
} | ||
|
||
return engine.QueryEngine | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
pub(crate) mod js_arg; | ||
pub(crate) mod js_to_quaint; | ||
|
||
#[cfg(feature = "mysql")] | ||
pub(crate) mod mysql; | ||
#[cfg(feature = "postgresql")] | ||
pub(crate) mod postgres; | ||
#[cfg(feature = "sqlite")] | ||
pub(crate) mod sqlite; | ||
|
||
pub use js_arg::JSArg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.