@ikonintegration/ikapi 2.6.3 → 2.6.5-beta2
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/package.json
CHANGED
|
@@ -79,6 +79,15 @@ export default class IKCache_Redis extends IKCache {
|
|
|
79
79
|
catch (e) { response = false; }
|
|
80
80
|
return response;
|
|
81
81
|
}
|
|
82
|
+
_isRedisClientV4() {
|
|
83
|
+
let isV4 = false;
|
|
84
|
+
try {
|
|
85
|
+
const test = require('redis').createClient({});
|
|
86
|
+
if (test.connect) isV4 = true;
|
|
87
|
+
}
|
|
88
|
+
catch (e) { }
|
|
89
|
+
return isV4;
|
|
90
|
+
}
|
|
82
91
|
async _connect() {
|
|
83
92
|
//No connection, but waiting connection queue is valid? wait until other promise
|
|
84
93
|
//fulfill this promire
|
|
@@ -97,11 +106,21 @@ export default class IKCache_Redis extends IKCache {
|
|
|
97
106
|
//Instantiate client and initiate connection
|
|
98
107
|
return new Promise((resolve, reject) => {
|
|
99
108
|
const redis = require("redis");
|
|
109
|
+
const isV4 = this._isRedisClientV4();
|
|
110
|
+
//
|
|
100
111
|
const connection = redis.createClient({
|
|
101
|
-
|
|
112
|
+
...(isV4 ? {
|
|
113
|
+
username: this.config.user, url: this.config.host,
|
|
114
|
+
...(this.config.enableTLS ? { socket: { tls: true } } /* https://docs.upstash.com/howto/connectwithtls */ : {})
|
|
115
|
+
} : {
|
|
116
|
+
host: this.config.host, user: this.config.user,
|
|
117
|
+
...(this.config.enableTLS ? { tls: {} } /* https://docs.upstash.com/howto/connectwithtls */ : {})
|
|
118
|
+
}),
|
|
102
119
|
password: this.config.password,
|
|
103
|
-
...(this.config.enableTLS ? { tls: {} } /* https://docs.upstash.com/howto/connectwithtls */ : {})
|
|
104
120
|
});
|
|
121
|
+
//redis v4 & v3 compatibility
|
|
122
|
+
if (connection && connection.connect) await connection.connect();
|
|
123
|
+
//
|
|
105
124
|
connection.on('connect', () => {
|
|
106
125
|
this.connection = connection;
|
|
107
126
|
if (this.awaitingConnectionQueue) this.awaitingConnectionQueue.forEach((resolve) => resolve());
|
package/src/Database/DDB/IKDB.js
CHANGED
|
@@ -16,7 +16,7 @@ export default class IKDB_DDB extends IKDB {
|
|
|
16
16
|
this.region = config.region;
|
|
17
17
|
//
|
|
18
18
|
const localConsole = (transaction ? transaction.logger : console);
|
|
19
|
-
if (config && this.tableName) { localConsole.debug(`Using table: ${this.tableName} on region: ${this.region}`); }
|
|
19
|
+
// if (config && this.tableName) { localConsole.debug(`Using table: ${this.tableName} on region: ${this.region}`); }
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async _getConnection() {
|
|
@@ -30,7 +30,7 @@ export default class IKDB_DDB extends IKDB {
|
|
|
30
30
|
localConsole.debug("Starting offline database connection");
|
|
31
31
|
this.connection = new AWS.DynamoDB(IKGlobals.DynamoDBLocalConfig);
|
|
32
32
|
} else {
|
|
33
|
-
localConsole.debug("Starting remote database connection");
|
|
33
|
+
// localConsole.debug("Starting remote database connection");
|
|
34
34
|
//setup ssl
|
|
35
35
|
const sslAgent = new HTTPS.Agent({ keepAlive: true, maxSockets: 50, rejectUnauthorized: true });
|
|
36
36
|
sslAgent.setMaxListeners(50);
|
|
@@ -21,7 +21,7 @@ export default class IKDBQueryPut extends IKDBQuery {
|
|
|
21
21
|
else val = AWS.DynamoDB.Converter.input(source[key]);
|
|
22
22
|
//valid
|
|
23
23
|
if (val != undefined) { this.putItems[key]= val; }
|
|
24
|
-
console.debug("Apppending key:", key, " val:", val);
|
|
24
|
+
// console.debug("Apppending key:", key, " val:", val);
|
|
25
25
|
return true;
|
|
26
26
|
} return false;
|
|
27
27
|
}
|
|
@@ -31,7 +31,7 @@ export default class IKDBQueryPut extends IKDBQuery {
|
|
|
31
31
|
const query = this.__rawQuery(dbManager.tableName);
|
|
32
32
|
localConsole.log('Putting item: ', query);
|
|
33
33
|
const resp = await dbManager.connection.putItem(query).promise();
|
|
34
|
-
localConsole.log('Raw result: ', resp);
|
|
34
|
+
// localConsole.log('Raw result: ', resp);
|
|
35
35
|
const unmarshalled = resp.Items.map(AWS.DynamoDB.Converter.unmarshall);
|
|
36
36
|
localConsole.log('Parsed result: ', unmarshalled);
|
|
37
37
|
return unmarshalled;
|