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
Changes from 3 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
13 changes: 13 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 quite on quit()
gkorland marked this conversation as resolved.
Show resolved Hide resolved
this.sentinelClient = client;

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

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

async quit() {
await super.quit();
if (this.sentinelClient) {
const reply = this.sentinelClient.quit();
return reply.then(() => {})
gkorland marked this conversation as resolved.
Show resolved Hide resolved
}
}
}