-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Have client.connect() return a Promise<RedisClient> #2602
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
Changes from 6 commits
61c5602
f42f774
b9e9a96
77e4617
3f8dbec
3a4fcad
10b411e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,19 @@ describe('Client', () => { | |
| }); | ||
| }); | ||
|
|
||
| describe('connect', () => { | ||
| testUtils.testWithClient('connect should return the clietn instance', async client => { | ||
| try { | ||
| assert.equal(await client.connect(), client); | ||
| } finally { | ||
| if (client.isOpen) await client.disconnect(); | ||
| } | ||
|
||
| }, { | ||
| ...GLOBAL.SERVERS.PASSWORD, | ||
| disableClientSetup: true | ||
| }); | ||
| }); | ||
|
|
||
| describe('authentication', () => { | ||
| testUtils.testWithClient('Client should be authenticated', async client => { | ||
| assert.equal( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -426,10 +426,11 @@ export default class RedisClient< | |
| }); | ||
| } | ||
|
|
||
| connect(): Promise<void> { | ||
| async connect() { | ||
| // see comment in constructor | ||
| this.#isolationPool ??= this.#initiateIsolationPool(); | ||
| return this.#socket.connect(); | ||
| await this.#socket.connect(); | ||
| return this as unknown as RedisClientType<M, F, S>; | ||
| } | ||
|
Comment on lines
429
to
434
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good! I am not familiar enough with TS to know if there's any meaningful difference here, but I've seen that style in the past so sounds good. |
||
|
|
||
| async commandsExecutor<C extends RedisCommand>( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.