falkordb 6.2.4 → 6.2.5
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/src/clients/client.d.ts +4 -0
- package/dist/src/clients/cluster.d.ts +1 -0
- package/dist/src/clients/cluster.js +8 -3
- package/dist/src/clients/nullClient.d.ts +1 -0
- package/dist/src/clients/nullClient.js +3 -0
- package/dist/src/clients/sentinel.d.ts +1 -0
- package/dist/src/clients/sentinel.js +18 -14
- package/dist/src/clients/single.d.ts +1 -0
- package/dist/src/clients/single.js +12 -11
- package/dist/src/falkordb.js +1 -1
- package/package.json +1 -1
|
@@ -23,6 +23,10 @@ export interface Client {
|
|
|
23
23
|
}[]>;
|
|
24
24
|
constraintCreate(graph: string, constraintType: ConstraintType, entityType: EntityType, label: string, ...properties: string[]): Promise<void>;
|
|
25
25
|
constraintDrop(graph: string, constraintType: ConstraintType, entityType: EntityType, label: string, ...properties: string[]): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `disconnect` instead
|
|
28
|
+
*/
|
|
26
29
|
quit(): Promise<void>;
|
|
30
|
+
disconnect(): Promise<void>;
|
|
27
31
|
getConnection(): Promise<SingleGraphConnection>;
|
|
28
32
|
}
|
|
@@ -53,4 +53,5 @@ export declare class Cluster implements Client {
|
|
|
53
53
|
constraintDrop(graph: string, constraintType: ConstraintType, entityType: EntityType, label: string, ...properties: string[]): Promise<void>;
|
|
54
54
|
profile<T>(graph: string, query: string): Promise<string | number | (string | number | (string | number | (string | number | (string | number | (string | number | (string | number | (string | number | (string | number | (string | number | (string | number | (string | number | /*elided*/ any | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined>;
|
|
55
55
|
quit(): Promise<void>;
|
|
56
|
+
disconnect(): Promise<void>;
|
|
56
57
|
}
|
|
@@ -11,7 +11,9 @@ class Cluster {
|
|
|
11
11
|
constructor(client) {
|
|
12
12
|
// Convert the single client options to a cluster client options
|
|
13
13
|
const redisClusterOption = client.options;
|
|
14
|
-
redisClusterOption.rootNodes = [
|
|
14
|
+
redisClusterOption.rootNodes = [
|
|
15
|
+
client.options,
|
|
16
|
+
];
|
|
15
17
|
// Remove the URL from the defaults so it won't override the dynamic cluster URLs
|
|
16
18
|
const defaults = lodash.cloneDeep(client.options);
|
|
17
19
|
defaults?.url && delete defaults.url;
|
|
@@ -26,7 +28,7 @@ class Cluster {
|
|
|
26
28
|
}
|
|
27
29
|
async init(falkordb) {
|
|
28
30
|
await this.#client
|
|
29
|
-
.on(
|
|
31
|
+
.on("error", (err) => falkordb.emit("error", err)) // Forward errors
|
|
30
32
|
.connect();
|
|
31
33
|
}
|
|
32
34
|
async query(graph, query, options, compact = true) {
|
|
@@ -73,7 +75,10 @@ class Cluster {
|
|
|
73
75
|
return this.#client.falkordb.profile(graph, query);
|
|
74
76
|
}
|
|
75
77
|
async quit() {
|
|
76
|
-
|
|
78
|
+
return this.disconnect();
|
|
79
|
+
}
|
|
80
|
+
async disconnect() {
|
|
81
|
+
const reply = this.#client.disconnect();
|
|
77
82
|
return reply.then(() => { });
|
|
78
83
|
}
|
|
79
84
|
}
|
|
@@ -37,4 +37,5 @@ export declare class NullClient implements Client {
|
|
|
37
37
|
constraintCreate(graph: string, constraintType: ConstraintType, entityType: EntityType, label: string, ...properties: string[]): Promise<void>;
|
|
38
38
|
constraintDrop(graph: string, constraintType: ConstraintType, entityType: EntityType, label: string, ...properties: string[]): Promise<void>;
|
|
39
39
|
quit(): Promise<void>;
|
|
40
|
+
disconnect(): Promise<void>;
|
|
40
41
|
}
|
|
@@ -29,26 +29,26 @@ class Sentinel extends single_1.Single {
|
|
|
29
29
|
const masters = await client.falkordb.sentinelMasters();
|
|
30
30
|
const details = extractDetails(masters);
|
|
31
31
|
if (details.length > 1) {
|
|
32
|
-
throw new Error(
|
|
32
|
+
throw new Error("Multiple masters are not supported");
|
|
33
33
|
}
|
|
34
34
|
// Connect to the server with the details from sentinel
|
|
35
35
|
const socketOptions = {
|
|
36
36
|
...redisOption.socket,
|
|
37
|
-
host: details[0][
|
|
38
|
-
port: parseInt(details[0][
|
|
37
|
+
host: details[0]["ip"],
|
|
38
|
+
port: parseInt(details[0]["port"]),
|
|
39
39
|
};
|
|
40
40
|
const serverOptions = {
|
|
41
41
|
...redisOption,
|
|
42
|
-
socket: socketOptions
|
|
42
|
+
socket: socketOptions,
|
|
43
43
|
};
|
|
44
44
|
const realClient = (0, client_1.createClient)(serverOptions);
|
|
45
|
-
// Save sentinel client to
|
|
45
|
+
// Save sentinel client to quit on quit()
|
|
46
46
|
this.sentinelClient = client;
|
|
47
47
|
// Set original client as sentinel and server client as client
|
|
48
48
|
this.client = realClient;
|
|
49
49
|
await realClient
|
|
50
|
-
.on(
|
|
51
|
-
console.debug(
|
|
50
|
+
.on("error", async (err) => {
|
|
51
|
+
console.debug("Error on server connection", err);
|
|
52
52
|
// Disconnect the client to avoid further errors and retries
|
|
53
53
|
realClient.disconnect();
|
|
54
54
|
// If error occurs on previous server connection, no need to reconnect
|
|
@@ -57,22 +57,26 @@ class Sentinel extends single_1.Single {
|
|
|
57
57
|
}
|
|
58
58
|
try {
|
|
59
59
|
await this.tryConnectSentinelServer(client, redisOption, falkordb);
|
|
60
|
-
console.debug(
|
|
60
|
+
console.debug("Connected to server");
|
|
61
61
|
}
|
|
62
62
|
catch (e) {
|
|
63
|
-
console.debug(
|
|
63
|
+
console.debug("Error on server reconnect", e);
|
|
64
64
|
// Forward errors if reconnection fails
|
|
65
|
-
falkordb.emit(
|
|
65
|
+
falkordb.emit("error", err);
|
|
66
66
|
}
|
|
67
67
|
})
|
|
68
68
|
.connect();
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
quit() {
|
|
71
|
+
return this.disconnect();
|
|
72
|
+
}
|
|
73
|
+
async disconnect() {
|
|
74
|
+
const promises = [super.disconnect()];
|
|
72
75
|
if (this.sentinelClient) {
|
|
73
|
-
const reply = this.sentinelClient.
|
|
74
|
-
|
|
76
|
+
const reply = this.sentinelClient.disconnect();
|
|
77
|
+
promises.push(reply.then(() => { }));
|
|
75
78
|
}
|
|
79
|
+
return Promise.all(promises).then(() => { });
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
exports.Sentinel = Sentinel;
|
|
@@ -47,5 +47,6 @@ export declare class Single implements Client {
|
|
|
47
47
|
constraintDrop(graph: string, constraintType: ConstraintType, entityType: EntityType, label: string, ...properties: string[]): Promise<void>;
|
|
48
48
|
copy<T>(srcGraph: string, destGraph: string): Promise<"OK">;
|
|
49
49
|
quit(): Promise<void>;
|
|
50
|
+
disconnect(): Promise<void>;
|
|
50
51
|
getConnection(): Promise<SingleGraphConnection>;
|
|
51
52
|
}
|
|
@@ -6,27 +6,25 @@ class Single {
|
|
|
6
6
|
#usePool;
|
|
7
7
|
constructor(client) {
|
|
8
8
|
this.client = client;
|
|
9
|
-
this.#usePool = !!
|
|
9
|
+
this.#usePool = !!this.client.options?.isolationPoolOptions;
|
|
10
10
|
}
|
|
11
11
|
init(falkordb) {
|
|
12
12
|
return Promise.resolve();
|
|
13
13
|
}
|
|
14
14
|
async query(graph, query, options, compact = true) {
|
|
15
|
-
const reply = this.#usePool
|
|
16
|
-
await this.client.executeIsolated(async (isolatedClient) => {
|
|
15
|
+
const reply = this.#usePool
|
|
16
|
+
? await this.client.executeIsolated(async (isolatedClient) => {
|
|
17
17
|
return isolatedClient.falkordb.query(graph, query, options, compact);
|
|
18
18
|
})
|
|
19
|
-
:
|
|
20
|
-
await this.client.falkordb.query(graph, query, options, compact);
|
|
19
|
+
: await this.client.falkordb.query(graph, query, options, compact);
|
|
21
20
|
return reply;
|
|
22
21
|
}
|
|
23
22
|
async roQuery(graph, query, options, compact = true) {
|
|
24
|
-
const reply = this.#usePool
|
|
25
|
-
await this.client.executeIsolated(async (isolatedClient) => {
|
|
23
|
+
const reply = this.#usePool
|
|
24
|
+
? await this.client.executeIsolated(async (isolatedClient) => {
|
|
26
25
|
return isolatedClient.falkordb.roQuery(graph, query, options, compact);
|
|
27
26
|
})
|
|
28
|
-
:
|
|
29
|
-
await this.client.falkordb.roQuery(graph, query, options, compact);
|
|
27
|
+
: await this.client.falkordb.roQuery(graph, query, options, compact);
|
|
30
28
|
return reply;
|
|
31
29
|
}
|
|
32
30
|
async delete(graph) {
|
|
@@ -87,8 +85,11 @@ class Single {
|
|
|
87
85
|
async copy(srcGraph, destGraph) {
|
|
88
86
|
return this.client.falkordb.copy(srcGraph, destGraph);
|
|
89
87
|
}
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
quit() {
|
|
89
|
+
return this.disconnect();
|
|
90
|
+
}
|
|
91
|
+
async disconnect() {
|
|
92
|
+
const reply = this.client.disconnect();
|
|
92
93
|
return reply.then(() => { });
|
|
93
94
|
}
|
|
94
95
|
async getConnection() {
|
package/dist/src/falkordb.js
CHANGED