You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
wip
This commit is contained in:
@@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
|
||||
import * as net from 'net';
|
||||
import * as tls from 'tls';
|
||||
import { ConnectionTimeoutError, ClientClosedError, SocketClosedUnexpectedlyError, ReconnectStrategyError } from '../errors';
|
||||
import { promiseTimeout } from '../utils';
|
||||
import { setTimeout } from 'timers/promises';
|
||||
import { RedisArgument } from '../RESP/types';
|
||||
|
||||
export interface RedisSocketCommonOptions {
|
||||
@@ -159,7 +159,7 @@ export default class RedisSocket extends EventEmitter {
|
||||
}
|
||||
|
||||
this.emit('error', err);
|
||||
await promiseTimeout(retryIn);
|
||||
await setTimeout(retryIn);
|
||||
this.emit('reconnecting');
|
||||
}
|
||||
} while (this._isOpen && !this._isReady);
|
||||
@@ -283,14 +283,6 @@ export default class RedisSocket extends EventEmitter {
|
||||
this.emit('end');
|
||||
}
|
||||
|
||||
cork(): void {
|
||||
this._socket?.cork();
|
||||
}
|
||||
|
||||
uncork(): void {
|
||||
this._socket?.uncork();
|
||||
}
|
||||
|
||||
ref(): void {
|
||||
this._isSocketUnrefed = false;
|
||||
this._socket?.ref();
|
||||
|
@@ -6,7 +6,7 @@
|
||||
// import { SQUARE_SCRIPT } from '../client/index.spec';
|
||||
// import { RootNodesUnavailableError } from '../errors';
|
||||
// import { spy } from 'sinon';
|
||||
// import { promiseTimeout } from '../utils';
|
||||
// import { setTimeout } from 'timers/promises';
|
||||
// import RedisClient from '../client';
|
||||
|
||||
// describe('Cluster', () => {
|
||||
@@ -284,7 +284,7 @@
|
||||
|
||||
// // wait for migrating node to be notified about the new topology
|
||||
// while ((await migratingClient.clusterInfo()).state !== 'ok') {
|
||||
// await promiseTimeout(50);
|
||||
// await setTimeout(50);
|
||||
// }
|
||||
|
||||
// // make sure to cause `MOVED` error
|
||||
@@ -340,7 +340,7 @@
|
||||
|
||||
// // wait for migrating node to be notified about the new topology
|
||||
// while ((await migratingClient.clusterInfo()).state !== 'ok') {
|
||||
// await promiseTimeout(50);
|
||||
// await setTimeout(50);
|
||||
// }
|
||||
|
||||
// const listener = spy();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import TestUtils from '@redis/test-utils';
|
||||
import { SinonSpy } from 'sinon';
|
||||
import { promiseTimeout } from './utils';
|
||||
import { setTimeout } from 'timers/promises';
|
||||
|
||||
const utils = new TestUtils({
|
||||
dockerImageName: 'redis',
|
||||
@@ -14,49 +14,49 @@ const DEBUG_MODE_ARGS = utils.isVersionGreaterThan([7]) ?
|
||||
[];
|
||||
|
||||
export const GLOBAL = {
|
||||
SERVERS: {
|
||||
OPEN: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS]
|
||||
},
|
||||
PASSWORD: {
|
||||
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
|
||||
clientOptions: {
|
||||
password: 'password'
|
||||
}
|
||||
}
|
||||
SERVERS: {
|
||||
OPEN: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS]
|
||||
},
|
||||
CLUSTERS: {
|
||||
OPEN: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS]
|
||||
},
|
||||
PASSWORD: {
|
||||
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
|
||||
clusterConfiguration: {
|
||||
defaults: {
|
||||
password: 'password'
|
||||
}
|
||||
}
|
||||
},
|
||||
WITH_REPLICAS: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
numberOfMasters: 2,
|
||||
numberOfReplicas: 1,
|
||||
clusterConfiguration: {
|
||||
useReplicas: true
|
||||
}
|
||||
}
|
||||
PASSWORD: {
|
||||
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
|
||||
clientOptions: {
|
||||
password: 'password'
|
||||
}
|
||||
}
|
||||
},
|
||||
CLUSTERS: {
|
||||
OPEN: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS]
|
||||
},
|
||||
PASSWORD: {
|
||||
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
|
||||
clusterConfiguration: {
|
||||
defaults: {
|
||||
password: 'password'
|
||||
}
|
||||
}
|
||||
},
|
||||
WITH_REPLICAS: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
numberOfMasters: 2,
|
||||
numberOfReplicas: 1,
|
||||
clusterConfiguration: {
|
||||
useReplicas: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export async function waitTillBeenCalled(spy: SinonSpy): Promise<void> {
|
||||
const start = process.hrtime.bigint(),
|
||||
calls = spy.callCount;
|
||||
const start = process.hrtime.bigint(),
|
||||
calls = spy.callCount;
|
||||
|
||||
do {
|
||||
if (process.hrtime.bigint() - start > 1_000_000_000) {
|
||||
throw new Error('Waiting for more than 1 second');
|
||||
}
|
||||
do {
|
||||
if (process.hrtime.bigint() - start > 1_000_000_000) {
|
||||
throw new Error('Waiting for more than 1 second');
|
||||
}
|
||||
|
||||
await promiseTimeout(50);
|
||||
} while (spy.callCount === calls);
|
||||
await setTimeout(50);
|
||||
} while (spy.callCount === calls);
|
||||
}
|
||||
|
@@ -1,3 +0,0 @@
|
||||
export function promiseTimeout(ms: number): Promise<void> {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
Reference in New Issue
Block a user