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.
@@ -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 = [client.options];
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('error', err => falkordb.emit('error', err)) // Forward errors
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
- const reply = this.#client.quit();
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
  }
@@ -61,5 +61,8 @@ class NullClient {
61
61
  quit() {
62
62
  throw new Error("Method not implemented.");
63
63
  }
64
+ disconnect() {
65
+ throw new Error("Method not implemented.");
66
+ }
64
67
  }
65
68
  exports.NullClient = NullClient;
@@ -9,4 +9,5 @@ export declare class Sentinel extends Single {
9
9
  */
10
10
  private tryConnectSentinelServer;
11
11
  quit(): Promise<void>;
12
+ disconnect(): Promise<void>;
12
13
  }
@@ -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('Multiple masters are not supported');
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]['ip'],
38
- port: parseInt(details[0]['port'])
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 quite on quit()
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('error', async (err) => {
51
- console.debug('Error on server connection', err);
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('Connected to server');
60
+ console.debug("Connected to server");
61
61
  }
62
62
  catch (e) {
63
- console.debug('Error on server reconnect', e);
63
+ console.debug("Error on server reconnect", e);
64
64
  // Forward errors if reconnection fails
65
- falkordb.emit('error', err);
65
+ falkordb.emit("error", err);
66
66
  }
67
67
  })
68
68
  .connect();
69
69
  }
70
- async quit() {
71
- await super.quit();
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.quit();
74
- return reply.then(() => { });
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 = !!(this.client.options?.isolationPoolOptions);
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
- async quit() {
91
- const reply = this.client.quit();
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() {
@@ -70,7 +70,7 @@ class FalkorDB extends events_1.EventEmitter {
70
70
  * Closes the client.
71
71
  */
72
72
  async close() {
73
- return this.#client.quit();
73
+ return this.#client.disconnect();
74
74
  }
75
75
  }
76
76
  exports.default = FalkorDB;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "falkordb",
3
- "version": "6.2.4",
3
+ "version": "6.2.5",
4
4
  "description": "A FalkorDB javascript library",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",