Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure sentinel is closed on quit() #238

Merged
merged 6 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "falkordb",
"version": "6.2.3",
"version": "6.2.4",
"description": "A FalkorDB javascript library",
"license": "MIT",
"main": "./dist/index.js",
Expand Down
16 changes: 16 additions & 0 deletions src/clients/sentinel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function extractDetails(masters: Array<Array<string>>) {

export class Sentinel extends Single {

private sentinelClient!: SingleGraphConnection;

init(falkordb: FalkorDB): Promise<void> {
const redisOption = (this.client.options ?? {}) as TypedRedisClientOptions;
return this.tryConnectSentinelServer(this.client, redisOption, falkordb);
Expand Down Expand Up @@ -50,6 +52,9 @@ export class Sentinel extends Single {
};
const realClient = createClient<{ falkordb: typeof commands }, RedisFunctions, RedisScripts>(serverOptions)

// Save sentinel client to quit on quit()
this.sentinelClient = client;

// Set original client as sentinel and server client as client
this.client = realClient;

Expand Down Expand Up @@ -78,5 +83,16 @@ export class Sentinel extends Single {
})
.connect();
}

async quit() {
const promises = [
super.quit()
];
if (this.sentinelClient) {
const reply = this.sentinelClient.quit();
promises.push(reply.then(() => {}))
}
return Promise.all(promises).then(() => {});
}
}