lesgo 2.1.7 → 2.1.9
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/config/rds.d.ts +4 -0
- package/dist/config/rds.js +10 -0
- package/dist/services/ElastiCacheRedisService/deleteRedisCache.d.ts +1 -1
- package/dist/services/ElastiCacheRedisService/deleteRedisCache.js +9 -4
- package/dist/services/ElastiCacheRedisService/scanRedisCache.js +20 -16
- package/dist/services/RDSAuroraMySQLProxyService/getMySQLProxyClient.js +7 -11
- package/dist/utils/cache/redis/deleteCache.d.ts +1 -1
- package/package.json +1 -1
package/dist/config/rds.d.ts
CHANGED
package/dist/config/rds.js
CHANGED
|
@@ -8,6 +8,16 @@ export default {
|
|
|
8
8
|
dbCredentialsSecretId:
|
|
9
9
|
process.env.LESGO_AWS_RDS_AURORA_MYSQL_PROXY_DB_CREDENTIALS_SECRET_ID,
|
|
10
10
|
host: process.env.LESGO_AWS_RDS_AURORA_MYSQL_PROXY_HOST,
|
|
11
|
+
port: process.env.LESGO_AWS_RDS_AURORA_MYSQL_PROXY_PORT,
|
|
12
|
+
connectionLimit: Number(
|
|
13
|
+
process.env.LESGO_AWS_RDS_AURORA_MYSQL_PROXY_CONNECTION_LIMIT || '10'
|
|
14
|
+
),
|
|
15
|
+
waitForConnections:
|
|
16
|
+
process.env.LESGO_AWS_RDS_AURORA_MYSQL_PROXY_WAIT_FOR_CONNECTIONS ===
|
|
17
|
+
'true',
|
|
18
|
+
queueLimit: Number(
|
|
19
|
+
process.env.LESGO_AWS_RDS_AURORA_MYSQL_PROXY_QUEUE_LIMIT || '0'
|
|
20
|
+
),
|
|
11
21
|
},
|
|
12
22
|
},
|
|
13
23
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ClientOptions } from '../../types/aws';
|
|
2
|
-
declare const deleteRedisCache: (keys: string | string[], clientOpts?: ClientOptions) => Promise<
|
|
2
|
+
declare const deleteRedisCache: (keys: string | string[], clientOpts?: ClientOptions) => Promise<void>;
|
|
3
3
|
export default deleteRedisCache;
|
|
@@ -38,14 +38,19 @@ const FILE = 'lesgo.services.ElastiCacheRedis.deleteRedisCache';
|
|
|
38
38
|
const deleteRedisCache = (keys, clientOpts) =>
|
|
39
39
|
__awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
const client = yield getElastiCacheRedisClient(clientOpts);
|
|
41
|
-
let resp;
|
|
42
41
|
if (!Array.isArray(keys)) {
|
|
43
42
|
keys = [keys];
|
|
44
43
|
}
|
|
45
44
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
if (keys.length > 0) {
|
|
46
|
+
for (const key of keys) {
|
|
47
|
+
// Keys to be deleted individually due to using Redis Cluster and key may exist across different nodes
|
|
48
|
+
// ioredis handles the routing of the key to the correct node automatically
|
|
49
|
+
const resp = yield client.del(key);
|
|
50
|
+
logger.debug(`${FILE}::CACHE_KEY_DELETED`, { resp, key });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
logger.debug(`${FILE}::ALL_KEYS_DELETED`, { keys });
|
|
49
54
|
} catch (err) {
|
|
50
55
|
throw new LesgoException(
|
|
51
56
|
'Failed to delete redis cache',
|
|
@@ -50,22 +50,26 @@ const scanRedisCache = (pattern, clientOpts) =>
|
|
|
50
50
|
{ key: 'pattern', type: 'string', required: true },
|
|
51
51
|
]);
|
|
52
52
|
const client = yield getElastiCacheRedisClient(clientOpts);
|
|
53
|
-
const
|
|
53
|
+
const allKeys = [];
|
|
54
54
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
const masterNodes = client.nodes('master');
|
|
56
|
+
for (const node of masterNodes) {
|
|
57
|
+
let cursor = '0';
|
|
58
|
+
do {
|
|
59
|
+
const [newCursor, keys] = yield node.scan(
|
|
60
|
+
cursor,
|
|
61
|
+
'MATCH',
|
|
62
|
+
pattern,
|
|
63
|
+
'COUNT',
|
|
64
|
+
100
|
|
65
|
+
);
|
|
66
|
+
cursor = newCursor;
|
|
67
|
+
if (keys.length > 0) {
|
|
68
|
+
allKeys.push(...keys);
|
|
69
|
+
}
|
|
70
|
+
} while (cursor !== '0');
|
|
71
|
+
}
|
|
72
|
+
logger.debug(`${FILE}::RECEIVED_RESPONSE`, { allKeys, input });
|
|
69
73
|
} catch (err) {
|
|
70
74
|
throw new LesgoException(
|
|
71
75
|
'Failed to scan redis cache',
|
|
@@ -78,6 +82,6 @@ const scanRedisCache = (pattern, clientOpts) =>
|
|
|
78
82
|
}
|
|
79
83
|
);
|
|
80
84
|
}
|
|
81
|
-
return
|
|
85
|
+
return allKeys;
|
|
82
86
|
});
|
|
83
87
|
export default scanRedisCache;
|
|
@@ -64,26 +64,22 @@ const getMySQLProxyClient = (connOptions, clientOpts) =>
|
|
|
64
64
|
singletonConn,
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
|
-
const validatedDbCredentials = validateFields(dbCredentials, [
|
|
68
|
-
{ key: 'host', type: 'string', required: true },
|
|
69
|
-
{ key: 'username', type: 'string', required: true },
|
|
70
|
-
{ key: 'password', type: 'string', required: true },
|
|
71
|
-
]);
|
|
72
67
|
const connOpts = Object.assign(
|
|
73
68
|
{
|
|
74
|
-
host: rdsConfig.aurora.mysql.proxy.host ||
|
|
69
|
+
host: rdsConfig.aurora.mysql.proxy.host || dbCredentials.host,
|
|
75
70
|
database: databaseName,
|
|
71
|
+
port: rdsConfig.aurora.mysql.proxy.port || dbCredentials.port || 3306,
|
|
72
|
+
connectionLimit: rdsConfig.aurora.mysql.proxy.connectionLimit || 10,
|
|
73
|
+
waitForConnections:
|
|
74
|
+
rdsConfig.aurora.mysql.proxy.waitForConnections || true,
|
|
75
|
+
queueLimit: rdsConfig.aurora.mysql.proxy.queueLimit || 0,
|
|
76
76
|
},
|
|
77
77
|
connOptions
|
|
78
78
|
);
|
|
79
79
|
logger.debug(`${FILE}::CONN_OPTS`, { connOpts });
|
|
80
80
|
const dbPool = createPool(
|
|
81
81
|
Object.assign(
|
|
82
|
-
{
|
|
83
|
-
user: validatedDbCredentials.username,
|
|
84
|
-
password: validatedDbCredentials.password,
|
|
85
|
-
connectionLimit: 20,
|
|
86
|
-
},
|
|
82
|
+
{ user: dbCredentials.username, password: dbCredentials.password },
|
|
87
83
|
connOpts
|
|
88
84
|
)
|
|
89
85
|
);
|
|
@@ -16,5 +16,5 @@ import { ClientOptions } from '../../../types/aws';
|
|
|
16
16
|
*
|
|
17
17
|
* await deleteCache(keys);
|
|
18
18
|
*/
|
|
19
|
-
declare const deleteCache: (keys: string | string[], clientOpts?: ClientOptions) => Promise<
|
|
19
|
+
declare const deleteCache: (keys: string | string[], clientOpts?: ClientOptions) => Promise<void>;
|
|
20
20
|
export default deleteCache;
|