snowflake-kysely-dialect 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SnowflakeDriver.d.ts +1 -0
- package/dist/SnowflakeDriver.js +17 -14
- package/package.json +1 -1
|
@@ -10,5 +10,6 @@ export declare class SnowflakeDriver implements Driver {
|
|
|
10
10
|
commitTransaction(conn: SnowflakeConnection): Promise<void>;
|
|
11
11
|
rollbackTransaction(conn: SnowflakeConnection): Promise<void>;
|
|
12
12
|
releaseConnection(conn: SnowflakeConnection): Promise<void>;
|
|
13
|
+
destroyConnection(conn: SnowflakeConnection): Promise<void>;
|
|
13
14
|
destroy(): Promise<void>;
|
|
14
15
|
}
|
package/dist/SnowflakeDriver.js
CHANGED
|
@@ -16,7 +16,8 @@ const DEFAULT_POOL_OPTIONS = {
|
|
|
16
16
|
class SnowflakeDriver {
|
|
17
17
|
#config;
|
|
18
18
|
#pool = null;
|
|
19
|
-
|
|
19
|
+
// Tracks the underlying SDK connection for each wrapper so we can release or destroy it.
|
|
20
|
+
#resources = new Map();
|
|
20
21
|
constructor(config) {
|
|
21
22
|
this.#config = config;
|
|
22
23
|
}
|
|
@@ -24,15 +25,10 @@ class SnowflakeDriver {
|
|
|
24
25
|
this.#pool = snowflake_sdk_1.default.createPool(this.#config.connection, { ...DEFAULT_POOL_OPTIONS, ...this.#config.poolOptions });
|
|
25
26
|
}
|
|
26
27
|
async acquireConnection() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.#pendingReleases.set(conn, resolveRelease);
|
|
32
|
-
resolveAcquire(conn);
|
|
33
|
-
});
|
|
34
|
-
}).catch(rejectAcquire);
|
|
35
|
-
});
|
|
28
|
+
const sdkConn = await this.#pool.acquire();
|
|
29
|
+
const conn = new SnowflakeConnection_js_1.SnowflakeConnection(sdkConn);
|
|
30
|
+
this.#resources.set(conn, sdkConn);
|
|
31
|
+
return conn;
|
|
36
32
|
}
|
|
37
33
|
async beginTransaction(conn) {
|
|
38
34
|
return conn.beginTransaction();
|
|
@@ -44,10 +40,17 @@ class SnowflakeDriver {
|
|
|
44
40
|
return conn.rollbackTransaction();
|
|
45
41
|
}
|
|
46
42
|
async releaseConnection(conn) {
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
this.#
|
|
50
|
-
release();
|
|
43
|
+
const sdkConn = this.#resources.get(conn);
|
|
44
|
+
if (sdkConn) {
|
|
45
|
+
this.#resources.delete(conn);
|
|
46
|
+
await this.#pool.release(sdkConn);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async destroyConnection(conn) {
|
|
50
|
+
const sdkConn = this.#resources.get(conn);
|
|
51
|
+
if (sdkConn) {
|
|
52
|
+
this.#resources.delete(conn);
|
|
53
|
+
await this.#pool.destroy(sdkConn);
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
async destroy() {
|