You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Add support for redis functions (#2020)
* fix #1906 - implement BITFIELD_RO * initial support for redis functions * fix test utils * redis functions commands and tests * upgrade deps * fix "Property 'uninstall' does not exist on type 'SinonFakeTimers'" * upgrade dockers version * Merge branch 'master' of github.com:redis/node-redis into functions * fix FUNCTION LIST WITHCODE and FUNCTION STATS * upgrade deps * set minimum version for FCALL and FCALL_RO * fix FUNCTION LOAD * FUNCTION LOAD * fix FUNCTION LOAD & FUNCTION LIST & FUNCTION LOAD WITHCODE * fix FUNCTION_LIST_WITHCODE test
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createConnection } from 'net';
|
||||
import { once } from 'events';
|
||||
import { RedisModules, RedisScripts } from '@node-redis/client/lib/commands';
|
||||
import { RedisModules, RedisFunctions, RedisScripts } from '@node-redis/client/lib/commands';
|
||||
import RedisClient, { RedisClientType } from '@node-redis/client/lib/client';
|
||||
import { promiseTimeout } from '@node-redis/client/lib/utils';
|
||||
import * as path from 'path';
|
||||
@@ -152,7 +152,11 @@ async function spawnRedisClusterNodeDocker(
|
||||
}
|
||||
}
|
||||
|
||||
async function waitForClusterState<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>): Promise<void> {
|
||||
async function waitForClusterState<
|
||||
M extends RedisModules,
|
||||
F extends RedisFunctions,
|
||||
S extends RedisScripts
|
||||
>(client: RedisClientType<M, F, S>): Promise<void> {
|
||||
while ((await client.clusterInfo()).state !== 'ok') {
|
||||
await promiseTimeout(500);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { RedisModules, RedisScripts } from '@node-redis/client/lib/commands';
|
||||
import { RedisModules, RedisFunctions, RedisScripts } from '@node-redis/client/lib/commands';
|
||||
import RedisClient, { RedisClientOptions, RedisClientType } from '@node-redis/client/lib/client';
|
||||
import RedisCluster, { RedisClusterOptions, RedisClusterType } from '@node-redis/client/lib/cluster';
|
||||
import { RedisServerDockerConfig, spawnRedisServer, spawnRedisCluster } from './dockers';
|
||||
@@ -15,15 +15,23 @@ interface CommonTestOptions {
|
||||
minimumDockerVersion?: Array<number>;
|
||||
}
|
||||
|
||||
interface ClientTestOptions<M extends RedisModules, S extends RedisScripts> extends CommonTestOptions {
|
||||
interface ClientTestOptions<
|
||||
M extends RedisModules,
|
||||
F extends RedisFunctions,
|
||||
S extends RedisScripts
|
||||
> extends CommonTestOptions {
|
||||
serverArguments: Array<string>;
|
||||
clientOptions?: Partial<RedisClientOptions<M, S>>;
|
||||
clientOptions?: Partial<RedisClientOptions<M, F, S>>;
|
||||
disableClientSetup?: boolean;
|
||||
}
|
||||
|
||||
interface ClusterTestOptions<M extends RedisModules, S extends RedisScripts> extends CommonTestOptions {
|
||||
interface ClusterTestOptions<
|
||||
M extends RedisModules,
|
||||
F extends RedisFunctions,
|
||||
S extends RedisScripts
|
||||
> extends CommonTestOptions {
|
||||
serverArguments: Array<string>;
|
||||
clusterConfiguration?: Partial<RedisClusterOptions<M, S>>;
|
||||
clusterConfiguration?: Partial<RedisClusterOptions<M, F, S>>;
|
||||
numberOfNodes?: number;
|
||||
}
|
||||
|
||||
@@ -93,10 +101,14 @@ export default class TestUtils {
|
||||
});
|
||||
}
|
||||
|
||||
testWithClient<M extends RedisModules, S extends RedisScripts>(
|
||||
testWithClient<
|
||||
M extends RedisModules,
|
||||
F extends RedisFunctions,
|
||||
S extends RedisScripts
|
||||
>(
|
||||
title: string,
|
||||
fn: (client: RedisClientType<M, S>) => Promise<unknown>,
|
||||
options: ClientTestOptions<M, S>
|
||||
fn: (client: RedisClientType<M, F, S>) => Promise<unknown>,
|
||||
options: ClientTestOptions<M, F, S>
|
||||
): void {
|
||||
let dockerPromise: ReturnType<typeof spawnRedisServer>;
|
||||
if (this.isVersionGreaterThan(options.minimumDockerVersion)) {
|
||||
@@ -138,16 +150,24 @@ export default class TestUtils {
|
||||
});
|
||||
}
|
||||
|
||||
static async #clusterFlushAll<M extends RedisModules, S extends RedisScripts>(cluster: RedisClusterType<M, S>): Promise<void> {
|
||||
static async #clusterFlushAll<
|
||||
M extends RedisModules,
|
||||
F extends RedisFunctions,
|
||||
S extends RedisScripts
|
||||
>(cluster: RedisClusterType<M, F, S>): Promise<void> {
|
||||
await Promise.all(
|
||||
cluster.getMasters().map(({ client }) => client.flushAll())
|
||||
);
|
||||
}
|
||||
|
||||
testWithCluster<M extends RedisModules, S extends RedisScripts>(
|
||||
testWithCluster<
|
||||
M extends RedisModules,
|
||||
F extends RedisFunctions,
|
||||
S extends RedisScripts
|
||||
>(
|
||||
title: string,
|
||||
fn: (cluster: RedisClusterType<M, S>) => Promise<void>,
|
||||
options: ClusterTestOptions<M, S>
|
||||
fn: (cluster: RedisClusterType<M, F, S>) => Promise<void>,
|
||||
options: ClusterTestOptions<M, F, S>
|
||||
): void {
|
||||
let dockersPromise: ReturnType<typeof spawnRedisCluster>;
|
||||
if (this.isVersionGreaterThan(options.minimumDockerVersion)) {
|
||||
|
Reference in New Issue
Block a user