@pi-r/oracle 0.9.3 → 0.10.0
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/client/index.js +12 -4
- package/client/pool.js +5 -1
- package/package.json +3 -3
package/client/index.js
CHANGED
|
@@ -38,7 +38,7 @@ function initOracleClient(credential, type) {
|
|
|
38
38
|
if (err instanceof Error) {
|
|
39
39
|
switch (err.code) {
|
|
40
40
|
case 'NJS-090':
|
|
41
|
-
this.addLog(this.statusType.WARN, err,
|
|
41
|
+
this.addLog(this.statusType.WARN, err, "oracle", credential.libDir);
|
|
42
42
|
break;
|
|
43
43
|
default:
|
|
44
44
|
this.writeFail(["Unable to configure client", 'oracledb'], err, { type: type ?? 65536, fatal: false });
|
|
@@ -104,7 +104,7 @@ async function setCredential(item) {
|
|
|
104
104
|
errors.push('connectString');
|
|
105
105
|
}
|
|
106
106
|
if (errors.length > 0) {
|
|
107
|
-
throw (0, types_1.errorMessage)("oracle",
|
|
107
|
+
throw (0, types_1.errorMessage)("oracle", "Invalid credentials", errors.join(', '));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
initOracleClient.call(this, credential);
|
|
@@ -112,10 +112,15 @@ async function setCredential(item) {
|
|
|
112
112
|
if (!usePool) {
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
+
else if (credential.sessionCallback) {
|
|
116
|
+
item.usePool = undefined;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
115
119
|
const poolAlias = credential.poolAlias;
|
|
116
120
|
let password, pool;
|
|
117
121
|
if ((0, types_1.isString)(usePool)) {
|
|
118
|
-
|
|
122
|
+
username = credential.user || poolAlias || configObject;
|
|
123
|
+
if (username) {
|
|
119
124
|
[password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
|
|
120
125
|
if (pool) {
|
|
121
126
|
pool.add(item, password);
|
|
@@ -142,7 +147,7 @@ async function setCredential(item) {
|
|
|
142
147
|
}
|
|
143
148
|
const config = this.getPoolConfig("oracle", password);
|
|
144
149
|
if (config) {
|
|
145
|
-
const { min, max, idle, queue_max, queue_idle, timeout } = config;
|
|
150
|
+
const { min, max, idle, queue_max, queue_idle, timeout, server_timeout } = config;
|
|
146
151
|
if (min >= 0) {
|
|
147
152
|
credential.poolMin ??= min;
|
|
148
153
|
}
|
|
@@ -161,6 +166,9 @@ async function setCredential(item) {
|
|
|
161
166
|
if (timeout >= 0) {
|
|
162
167
|
credential.connectTimeout ??= idle / 1000;
|
|
163
168
|
}
|
|
169
|
+
if (server_timeout > 0) {
|
|
170
|
+
credential.transportConnectTimeout ??= server_timeout / 1000;
|
|
171
|
+
}
|
|
164
172
|
}
|
|
165
173
|
const poolKey = DbPool.asString(credential);
|
|
166
174
|
if ((pool = POOL_STATE[poolKey]) && !pool.closed) {
|
package/client/pool.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
const DbPool = require('@e-mc/db/pool');
|
|
3
3
|
const POOL_ACTIVE = new WeakSet();
|
|
4
4
|
class OraclePool extends DbPool {
|
|
5
|
+
static CACHE_UNUSED = ['connectTimeout', 'transportConnectTimeout', 'expireTime', 'poolMax', 'poolMin', 'poolIncrement', 'poolTimeout', 'poolPingInterval', 'poolMaxPerShard', 'queueMax', 'queueRequests', 'queueTimeout', 'enableStatistics', 'sodaMetaDataCache', 'stmtCacheSize', 'httpsProxy', 'httpsProxyPort'];
|
|
6
|
+
static CACHE_IGNORE = ['sessionCallback'];
|
|
5
7
|
static asString(credential) {
|
|
6
8
|
if (credential.connectString && (credential.user && credential.password || credential.externalAuth) || credential.poolAlias) {
|
|
7
9
|
return JSON.stringify(this.removeUUIDKey(credential));
|
|
@@ -9,6 +11,9 @@ class OraclePool extends DbPool {
|
|
|
9
11
|
return super.asString(credential);
|
|
10
12
|
}
|
|
11
13
|
static sanitize(credential) {
|
|
14
|
+
if (!this.canCache(credential)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
12
17
|
if (!POOL_ACTIVE.has(credential) || credential.uuidKey) {
|
|
13
18
|
return credential;
|
|
14
19
|
}
|
|
@@ -46,5 +51,4 @@ class OraclePool extends DbPool {
|
|
|
46
51
|
return this.client.status === 6002;
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
OraclePool.CACHE_UNUSED = ['connectTimeout', 'transportConnectTimeout', 'expireTime', 'poolMax', 'poolMin', 'poolIncrement', 'poolTimeout', 'poolPingInterval', 'poolMaxPerShard', 'queueMax', 'queueRequests', 'queueTimeout', 'enableStatistics', 'sodaMetaDataCache', 'stmtCacheSize'];
|
|
50
54
|
module.exports = OraclePool;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oracle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Oracle client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/db": "^0.
|
|
24
|
-
"@e-mc/types": "^0.
|
|
23
|
+
"@e-mc/db": "^0.12.0",
|
|
24
|
+
"@e-mc/types": "^0.12.0",
|
|
25
25
|
"oracledb": "^6.8.0"
|
|
26
26
|
}
|
|
27
27
|
}
|