Skip to content

Commit 2455ab2

Browse files
committed
wip
1 parent 9d049c3 commit 2455ab2

File tree

6 files changed

+55
-65
lines changed

6 files changed

+55
-65
lines changed

packages/client/lib/client/socket.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
22
import * as net from 'net';
33
import * as tls from 'tls';
44
import { ConnectionTimeoutError, ClientClosedError, SocketClosedUnexpectedlyError, ReconnectStrategyError } from '../errors';
5-
import { promiseTimeout } from '../utils';
5+
import { setTimeout } from 'timers/promises';
66
import { RedisArgument } from '../RESP/types';
77

88
export interface RedisSocketCommonOptions {
@@ -159,7 +159,7 @@ export default class RedisSocket extends EventEmitter {
159159
}
160160

161161
this.emit('error', err);
162-
await promiseTimeout(retryIn);
162+
await setTimeout(retryIn);
163163
this.emit('reconnecting');
164164
}
165165
} while (this._isOpen && !this._isReady);
@@ -283,14 +283,6 @@ export default class RedisSocket extends EventEmitter {
283283
this.emit('end');
284284
}
285285

286-
cork(): void {
287-
this._socket?.cork();
288-
}
289-
290-
uncork(): void {
291-
this._socket?.uncork();
292-
}
293-
294286
ref(): void {
295287
this._isSocketUnrefed = false;
296288
this._socket?.ref();

packages/client/lib/cluster/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// import { SQUARE_SCRIPT } from '../client/index.spec';
77
// import { RootNodesUnavailableError } from '../errors';
88
// import { spy } from 'sinon';
9-
// import { promiseTimeout } from '../utils';
9+
// import { setTimeout } from 'timers/promises';
1010
// import RedisClient from '../client';
1111

1212
// describe('Cluster', () => {
@@ -284,7 +284,7 @@
284284

285285
// // wait for migrating node to be notified about the new topology
286286
// while ((await migratingClient.clusterInfo()).state !== 'ok') {
287-
// await promiseTimeout(50);
287+
// await setTimeout(50);
288288
// }
289289

290290
// // make sure to cause `MOVED` error
@@ -340,7 +340,7 @@
340340

341341
// // wait for migrating node to be notified about the new topology
342342
// while ((await migratingClient.clusterInfo()).state !== 'ok') {
343-
// await promiseTimeout(50);
343+
// await setTimeout(50);
344344
// }
345345

346346
// const listener = spy();

packages/client/lib/test-utils.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import TestUtils from '@redis/test-utils';
22
import { SinonSpy } from 'sinon';
3-
import { promiseTimeout } from './utils';
3+
import { setTimeout } from 'timers/promises';
44

55
const utils = new TestUtils({
66
dockerImageName: 'redis',
@@ -14,49 +14,49 @@ const DEBUG_MODE_ARGS = utils.isVersionGreaterThan([7]) ?
1414
[];
1515

1616
export const GLOBAL = {
17-
SERVERS: {
18-
OPEN: {
19-
serverArguments: [...DEBUG_MODE_ARGS]
20-
},
21-
PASSWORD: {
22-
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
23-
clientOptions: {
24-
password: 'password'
25-
}
26-
}
17+
SERVERS: {
18+
OPEN: {
19+
serverArguments: [...DEBUG_MODE_ARGS]
20+
},
21+
PASSWORD: {
22+
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
23+
clientOptions: {
24+
password: 'password'
25+
}
26+
}
27+
},
28+
CLUSTERS: {
29+
OPEN: {
30+
serverArguments: [...DEBUG_MODE_ARGS]
2731
},
28-
CLUSTERS: {
29-
OPEN: {
30-
serverArguments: [...DEBUG_MODE_ARGS]
31-
},
32-
PASSWORD: {
33-
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
34-
clusterConfiguration: {
35-
defaults: {
36-
password: 'password'
37-
}
38-
}
39-
},
40-
WITH_REPLICAS: {
41-
serverArguments: [...DEBUG_MODE_ARGS],
42-
numberOfMasters: 2,
43-
numberOfReplicas: 1,
44-
clusterConfiguration: {
45-
useReplicas: true
46-
}
32+
PASSWORD: {
33+
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
34+
clusterConfiguration: {
35+
defaults: {
36+
password: 'password'
4737
}
38+
}
39+
},
40+
WITH_REPLICAS: {
41+
serverArguments: [...DEBUG_MODE_ARGS],
42+
numberOfMasters: 2,
43+
numberOfReplicas: 1,
44+
clusterConfiguration: {
45+
useReplicas: true
46+
}
4847
}
48+
}
4949
};
5050

5151
export async function waitTillBeenCalled(spy: SinonSpy): Promise<void> {
52-
const start = process.hrtime.bigint(),
53-
calls = spy.callCount;
52+
const start = process.hrtime.bigint(),
53+
calls = spy.callCount;
5454

55-
do {
56-
if (process.hrtime.bigint() - start > 1_000_000_000) {
57-
throw new Error('Waiting for more than 1 second');
58-
}
55+
do {
56+
if (process.hrtime.bigint() - start > 1_000_000_000) {
57+
throw new Error('Waiting for more than 1 second');
58+
}
5959

60-
await promiseTimeout(50);
61-
} while (spy.callCount === calls);
60+
await setTimeout(50);
61+
} while (spy.callCount === calls);
6262
}

packages/client/lib/utils.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
77
"files": [
8-
"dist/"
8+
"dist/",
9+
"!dist/tsconfig.tsbuildinfo"
910
],
1011
"scripts": {
1112
"test": "nyc -r text-summary -r lcov mocha -r source-map-support/register -r ts-node/register './lib/**/*.spec.ts'"

packages/redis/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ The Node Redis client class is an Nodejs EventEmitter and it emits an event each
167167
168168
> The client will not emit [any other events](../../docs/v3-to-v4.md#all-the-removed-events) beyond those listed above.
169169
170+
### Links
171+
172+
- [Multi](../../docs/multi.md).
173+
- [Pub/Sub](../../docs/pub-sub.md).
174+
- [Scan Iterators](../../docs/scan-iterators.md).
175+
- [Programmability](../../docs/programmability.md).
176+
- [Command Options](../../docs/command-options.md).
177+
- [Blocking Commands](../../docs/blocking-commands.md).
178+
- [Clustering](../../docs/clustering.md).
179+
170180
## Supported Redis versions
171181

172182
Node Redis is supported with the following versions of Redis:
@@ -192,13 +202,3 @@ Thank you to all the people who already contributed to Node Redis!
192202
## License
193203

194204
This repository is licensed under the "MIT" license. See [LICENSE](../../LICENSE).
195-
196-
### Links
197-
198-
- [Multi](../../docs/multi.md).
199-
- [Pub/Sub](../../docs/pub-sub.md).
200-
- [Scan Iterators](../../docs/scan-iterators.md).
201-
- [Programmability](../../docs/programmability.md).
202-
- [Command Options](../../docs/command-options.md).
203-
- [Blocking Commands](../../docs/blocking-commands.md).
204-
- [Clustering](../../docs/clustering.md).

0 commit comments

Comments
 (0)