@technicity/data-service-generator 0.11.1 → 0.11.2
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/runtime/Cache.d.ts +6 -5
- package/dist/runtime/Cache.js +33 -9
- package/dist/runtime/Stats.d.ts +3 -3
- package/package.json +1 -1
package/dist/runtime/Cache.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { RedisClientType } from "redis";
|
|
1
|
+
import { RedisClientType, RedisClusterType } from "redis";
|
|
2
2
|
import { TResolveParams } from "./IRuntime";
|
|
3
3
|
import Stats from "./Stats";
|
|
4
4
|
export declare type RedisConfig = {
|
|
5
5
|
url: string;
|
|
6
|
-
tls
|
|
7
|
-
db
|
|
8
|
-
socketTimeout
|
|
6
|
+
tls?: boolean;
|
|
7
|
+
db?: number;
|
|
8
|
+
socketTimeout?: number;
|
|
9
|
+
clusterMode?: boolean;
|
|
9
10
|
};
|
|
10
11
|
declare class Cache {
|
|
11
|
-
client: RedisClientType;
|
|
12
|
+
client: RedisClientType | RedisClusterType;
|
|
12
13
|
waiting?: Set<() => void> | undefined;
|
|
13
14
|
logs?: boolean;
|
|
14
15
|
stats?: Stats;
|
package/dist/runtime/Cache.js
CHANGED
|
@@ -9,16 +9,40 @@ class Cache {
|
|
|
9
9
|
this.waiting = new Set();
|
|
10
10
|
if (debug?.includes("Cache"))
|
|
11
11
|
this.logs = true;
|
|
12
|
-
const { url
|
|
12
|
+
const { url } = redisConfig;
|
|
13
|
+
const tls = redisConfig.tls ? true : false;
|
|
14
|
+
const clusterMode = redisConfig.clusterMode ? true : false;
|
|
13
15
|
const scheme = tls ? "rediss://" : "redis://";
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const db = redisConfig.db == null ? 0 : redisConfig.db;
|
|
17
|
+
const socketTimeout = redisConfig.socketTimeout == null ? 50000 : redisConfig.socketTimeout;
|
|
18
|
+
let client = undefined;
|
|
19
|
+
if (clusterMode) {
|
|
20
|
+
client = (0, redis_1.createCluster)({
|
|
21
|
+
rootNodes: [
|
|
22
|
+
{
|
|
23
|
+
url: `${scheme}${url}`
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
defaults: {
|
|
27
|
+
socket: {
|
|
28
|
+
tls,
|
|
29
|
+
rejectUnauthorized: false,
|
|
30
|
+
connectTimeout: socketTimeout
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
client = (0, redis_1.createClient)({
|
|
37
|
+
url: `${scheme}${url}/${db}`,
|
|
38
|
+
socket: {
|
|
39
|
+
tls,
|
|
40
|
+
rejectUnauthorized: false,
|
|
41
|
+
connectTimeout: socketTimeout
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
this.client = client;
|
|
22
46
|
client.connect();
|
|
23
47
|
client.on("connect", () => {
|
|
24
48
|
if (this.waiting)
|
package/dist/runtime/Stats.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RedisClientType } from
|
|
1
|
+
import { RedisClientType, RedisClusterType } from "@redis/client";
|
|
2
2
|
declare class Stats {
|
|
3
|
-
client: RedisClientType<any>;
|
|
4
|
-
constructor(client: RedisClientType<any>);
|
|
3
|
+
client: RedisClientType<any> | RedisClusterType<any>;
|
|
4
|
+
constructor(client: RedisClientType<any> | RedisClusterType<any>);
|
|
5
5
|
updateStats: (ms: number, category: string) => Promise<void>;
|
|
6
6
|
}
|
|
7
7
|
declare namespace timer {
|