lambda-toolkit 0.0.7-beta → 0.0.8-beta
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/index.js +50 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1446,6 +1446,7 @@ const aws = __webpack_require__( 4870 );
|
|
|
1446
1446
|
const epoch = __webpack_require__( 3830 );
|
|
1447
1447
|
const math = __webpack_require__( 943 );
|
|
1448
1448
|
const object = __webpack_require__( 5762 );
|
|
1449
|
+
const redis = __webpack_require__( 4528 );
|
|
1449
1450
|
const string = __webpack_require__( 268 );
|
|
1450
1451
|
const utils = __webpack_require__( 6878 );
|
|
1451
1452
|
|
|
@@ -1456,6 +1457,7 @@ module.exports = {
|
|
|
1456
1457
|
LambdaApi,
|
|
1457
1458
|
math,
|
|
1458
1459
|
object,
|
|
1460
|
+
redis,
|
|
1459
1461
|
string,
|
|
1460
1462
|
utils
|
|
1461
1463
|
};
|
|
@@ -2170,6 +2172,54 @@ const change = ( obj, keepAllCaps ) =>
|
|
|
2170
2172
|
module.exports = ( obj, { keepAllCaps = false } = {} ) => change( obj, keepAllCaps );
|
|
2171
2173
|
|
|
2172
2174
|
|
|
2175
|
+
/***/ }),
|
|
2176
|
+
|
|
2177
|
+
/***/ 5422:
|
|
2178
|
+
/***/ ((module) => {
|
|
2179
|
+
|
|
2180
|
+
global.__redisInstances = {};
|
|
2181
|
+
|
|
2182
|
+
/**
|
|
2183
|
+
* Create a redis client instance
|
|
2184
|
+
* @param {Object} redis Redis npm dependency
|
|
2185
|
+
* @param {String} address Redis DB address (either RW or RO)
|
|
2186
|
+
* @returns redisClient A new redis client instance connected to the database
|
|
2187
|
+
*/
|
|
2188
|
+
module.exports = async ( { redis, address, protocol = 'rediss', port = 6379 } ) => {
|
|
2189
|
+
if ( global.__redisInstances[address] ) {
|
|
2190
|
+
try {
|
|
2191
|
+
const r = await global.__redisInstances[address].ping();
|
|
2192
|
+
if ( r === 'PONG' ) {
|
|
2193
|
+
return global.__redisInstances[address];
|
|
2194
|
+
} else {
|
|
2195
|
+
delete global.__redisInstances[address];
|
|
2196
|
+
}
|
|
2197
|
+
} catch {
|
|
2198
|
+
delete global.__redisInstances[address];
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
const client = redis.createClient( { url: `${protocol}://${address}:${port}`, socket: { keepAlive: 15000 } } );
|
|
2203
|
+
|
|
2204
|
+
await client.connect();
|
|
2205
|
+
|
|
2206
|
+
global.__redisInstances[address] = client;
|
|
2207
|
+
return client;
|
|
2208
|
+
};
|
|
2209
|
+
|
|
2210
|
+
|
|
2211
|
+
/***/ }),
|
|
2212
|
+
|
|
2213
|
+
/***/ 4528:
|
|
2214
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
2215
|
+
|
|
2216
|
+
const createClient = __webpack_require__( 5422 );
|
|
2217
|
+
|
|
2218
|
+
module.exports = {
|
|
2219
|
+
createClient
|
|
2220
|
+
};
|
|
2221
|
+
|
|
2222
|
+
|
|
2173
2223
|
/***/ }),
|
|
2174
2224
|
|
|
2175
2225
|
/***/ 3914:
|