From d2d5585b56192cadce2910b82a51f569421a6ea6 Mon Sep 17 00:00:00 2001 From: Yi-Pin Chen Date: Wed, 24 Jul 2024 09:38:50 -0700 Subject: [PATCH 1/3] Node: added FCALL and FCALL_RO commands Signed-off-by: Yi-Pin Chen --- node/src/BaseClient.ts | 63 ++++++++++++++++++++++- node/src/Commands.ts | 72 +++++++++++++++++++++++---- node/src/GlideClusterClient.ts | 63 +++++++++++++++++++++++ node/src/Transaction.ts | 38 ++++++++++++++ node/tests/RedisClient.test.ts | 30 +++-------- node/tests/RedisClusterClient.test.ts | 21 ++++---- node/tests/TestUtilities.ts | 4 ++ 7 files changed, 245 insertions(+), 46 deletions(-) diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index 9119493f3c..d5d43709e3 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -13,6 +13,7 @@ import { Buffer, BufferWriter, Reader, Writer } from "protobufjs"; import { AggregationType, ExpireOptions, + GeoUnit, InsertPosition, KeyWeight, RangeByIndex, @@ -34,10 +35,12 @@ import { createExists, createExpire, createExpireAt, + createFCall, + createFCallReadOnly, createGeoAdd, createGeoDist, - createGeoPos, createGeoHash, + createGeoPos, createGet, createGetBit, createGetDel, @@ -129,7 +132,6 @@ import { createZRevRank, createZRevRankWithScore, createZScore, - GeoUnit, } from "./Commands"; import { BitOffsetOptions } from "./commands/BitOffsetOptions"; import { GeoAddOptions } from "./commands/geospatial/GeoAddOptions"; @@ -3330,6 +3332,63 @@ export class BaseClient { return this.createWritePromise(createObjectRefcount(key)); } + /** + * Invokes a previously loaded function. + * + * See https://valkey.io/commands/fcall/ for more details. + * + * since Valkey version 7.0.0. + * + * @remarks When in cluster mode, all `keys` must map to the same hash slot. + * @param func - The function name. + * @param keys - A list of `keys` accessed by the function. To ensure the correct execution of functions, + * all names of keys that a function accesses must be explicitly provided as `keys`. + * @param args - A list of `function` arguments and it should not represent names of keys. + * @returns The invoked function's return value. + * + * @example + * ```typescript + * const response = await client.fcall("Deep_Thought"); + * console.log(response); // Output: Returns the function's return value. + * ``` + */ + public fcall( + func: string, + keys?: string[], + args?: string[], + ): Promise { + return this.createWritePromise(createFCall(func, keys, args)); + } + + /** + * Invokes a previously loaded read-only function. + * + * See https://valkey.io/commands/fcall/ for more details. + * + * since Valkey version 7.0.0. + * + * @remarks When in cluster mode, all `keys` must map to the same hash slot. + * @param func - The function name. + * @param keys - A list of `keys` accessed by the function. To ensure the correct execution of functions, + * all names of keys that a function accesses must be explicitly provided as `keys`. + * @param args - A list of `function` arguments and it should not represent names of keys. + * @returns The invoked function's return value. + * + * @example + * ```typescript + * const response = await client.fcallReadOnly("Deep_Thought", ["key1"], ["Answer", "to", "the", + * "Ultimate", "Question", "of", "Life,", "the", "Universe,", "and", "Everything"]); + * console.log(response); // Output: 42 # The return value on the function that was execute. + * ``` + */ + public fcallReadonly( + func: string, + keys?: string[], + args?: string[], + ): Promise { + return this.createWritePromise(createFCallReadOnly(func, keys, args)); + } + /** * Returns the index of the first occurrence of `element` inside the list specified by `key`. If no * match is found, `null` is returned. If the `count` option is specified, then the function returns diff --git a/node/src/Commands.ts b/node/src/Commands.ts index b34e7be2b1..fe0b2fa50c 100644 --- a/node/src/Commands.ts +++ b/node/src/Commands.ts @@ -1584,6 +1584,56 @@ export function createBLPop( return createCommand(RequestType.BLPop, args); } +/** + * @internal + */ +export function createFCall( + func: string, + keys?: string[], + args?: string[], +): command_request.Command { + const params: string[] = []; + params.push(func); + + if (keys !== undefined) { + params.push(keys.length.toString()); + params.push(...keys); + } else { + params.push("0"); + } + + if (args !== undefined) { + params.push(...args); + } + + return createCommand(RequestType.FCall, params); +} + +/** + * @internal + */ +export function createFCallReadOnly( + func: string, + keys?: string[], + args?: string[], +): command_request.Command { + const params: string[] = []; + params.push(func); + + if (keys !== undefined) { + params.push(keys.length.toString()); + params.push(...keys); + } else { + params.push("0"); + } + + if (args !== undefined) { + params.push(...args); + } + + return createCommand(RequestType.FCallReadOnly, params); +} + /** * @internal */ @@ -1593,6 +1643,17 @@ export function createFunctionDelete( return createCommand(RequestType.FunctionDelete, [libraryCode]); } +/** + * @internal + */ +export function createFunctionFlush(mode?: FlushMode): command_request.Command { + if (mode) { + return createCommand(RequestType.FunctionFlush, [mode.toString()]); + } else { + return createCommand(RequestType.FunctionFlush, []); + } +} + /** * @internal */ @@ -1616,17 +1677,6 @@ export function createBitCount( return createCommand(RequestType.BitCount, args); } -/** - * @internal - */ -export function createFunctionFlush(mode?: FlushMode): command_request.Command { - if (mode) { - return createCommand(RequestType.FunctionFlush, [mode.toString()]); - } else { - return createCommand(RequestType.FunctionFlush, []); - } -} - export type StreamReadOptions = { /** * If set, the read request will block for the set amount of milliseconds or diff --git a/node/src/GlideClusterClient.ts b/node/src/GlideClusterClient.ts index d552469812..7a94cd3514 100644 --- a/node/src/GlideClusterClient.ts +++ b/node/src/GlideClusterClient.ts @@ -21,6 +21,8 @@ import { createCustomCommand, createDBSize, createEcho, + createFCall, + createFCallReadOnly, createFlushAll, createFlushDB, createFunctionDelete, @@ -659,6 +661,67 @@ export class GlideClusterClient extends BaseClient { ); } + /** + * Invokes a previously loaded function. + * + * See https://valkey.io/commands/fcall/ for more details. + * + * since Valkey version 7.0.0. + * + * @param func - The function name. + * @param args - A list of `function` arguments and it should not represent names of keys. + * @param route - The command will be routed to a random node, unless `route` is provided, in which + * case the client will route the command to the nodes defined by `route`. + * @returns The invoked function's return value. + * + * @example + * ```typescript + * const response = await client.fcallRoute("Deep_Thought", undefined, "randomNode"); + * console.log(response); // Output: Returns the function's return value. + * ``` + */ + public fcallRoute( + func: string, + args?: string[], + route?: Routes, + ): Promise { + return this.createWritePromise( + createFCall(func, undefined, args), + toProtobufRoute(route), + ); + } + + /** + * Invokes a previously loaded read-only function. + * + * See https://valkey.io/commands/fcall/ for more details. + * + * since Valkey version 7.0.0. + * + * @param func - The function name. + * @param args - A list of `function` arguments and it should not represent names of keys. + * @param route - The command will be routed to a random node, unless `route` is provided, in which + * case the client will route the command to the nodes defined by `route`. + * @returns The invoked function's return value. + * + * @example + * ```typescript + * const response = await client.fcallReadOnly("Deep_Thought", ["Answer", "to", "the", "Ultimate", + * "Question", "of", "Life,", "the", "Universe,", "and", "Everything"], "randomNode"); + * console.log(response); // Output: 42 # The return value on the function that was execute. + * ``` + */ + public fcallReadonlyRoute( + func: string, + args?: string[], + route?: Routes, + ): Promise { + return this.createWritePromise( + createFCallReadOnly(func, undefined, args), + toProtobufRoute(route), + ); + } + /** * Deletes a library and all its functions. * diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index 8a9b1b61e0..0d242d91ab 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -37,6 +37,8 @@ import { createExists, createExpire, createExpireAt, + createFCall, + createFCallReadOnly, createFlushAll, createFlushDB, createFunctionDelete, @@ -1854,6 +1856,42 @@ export class BaseTransaction> { return this.addAndReturn(createLolwut(options)); } + /** + * Invokes a previously loaded function. + * + * See https://valkey.io/commands/fcall/ for more details. + * + * since Valkey version 7.0.0. + * + * @param func - The function name. + * @param keys - A list of keys accessed by the function. To ensure the correct execution of functions, + * all names of keys that a function accesses must be explicitly provided as `keys`. + * @param args - A list of `function` arguments and it should not represent names of keys. + * + * Command Response - The invoked function's return value. + */ + public fcall(func: string, keys?: string[], args?: string[]): T { + return this.addAndReturn(createFCall(func, keys, args)); + } + + /** + * Invokes a previously loaded read-only function. + * + * See https://valkey.io/commands/fcall/ for more details. + * + * since Valkey version 7.0.0. + * + * @param func - The function name. + * @param keys - A list of keys accessed by the function. To ensure the correct execution of functions, + * all names of keys that a function accesses must be explicitly provided as `keys`. + * @param args - A list of `function` arguments and it should not represent names of keys. + * + * Command Response - The invoked function's return value. + */ + public fcallReadonly(func: string, keys?: string[], args?: string[]): T { + return this.addAndReturn(createFCallReadOnly(func, keys, args)); + } + /** * Deletes a library and all its functions. * diff --git a/node/tests/RedisClient.test.ts b/node/tests/RedisClient.test.ts index 853a8aa769..fe0b78e73f 100644 --- a/node/tests/RedisClient.test.ts +++ b/node/tests/RedisClient.test.ts @@ -397,19 +397,10 @@ describe("GlideClient", () => { checkSimple(await client.functionLoad(code)).toEqual(libName); checkSimple( - await client.customCommand([ - "FCALL", - funcName, - "0", - "one", - "two", - ]), + await client.fcall(funcName, undefined, ["one", "two"]), ).toEqual("one"); checkSimple( - await client.customCommand([ - "FCALL_RO", - funcName, - "0", + await client.fcallReadonly(funcName, undefined, [ "one", "two", ]), @@ -441,20 +432,11 @@ describe("GlideClient", () => { libName, ); - expect( - await client.customCommand([ - "FCALL", - func2Name, - "0", - "one", - "two", - ]), + checkSimple( + await client.fcall(func2Name, undefined, ["one", "two"]), ).toEqual(2); - expect( - await client.customCommand([ - "FCALL_RO", - func2Name, - "0", + checkSimple( + await client.fcallReadonly(func2Name, undefined, [ "one", "two", ]), diff --git a/node/tests/RedisClusterClient.test.ts b/node/tests/RedisClusterClient.test.ts index e039c96ad5..fb170a8fbb 100644 --- a/node/tests/RedisClusterClient.test.ts +++ b/node/tests/RedisClusterClient.test.ts @@ -610,8 +610,9 @@ describe("GlideClusterClient", () => { await client.functionLoad(code), ).toEqual(libName); // call functions from that library to confirm that it works - let fcall = await client.customCommand( - ["FCALL", funcName, "0", "one", "two"], + let fcall = await client.fcallRoute( + funcName, + ["one", "two"], route, ); checkClusterResponse( @@ -620,9 +621,9 @@ describe("GlideClusterClient", () => { (value) => checkSimple(value).toEqual("one"), ); - - fcall = await client.customCommand( - ["FCALL_RO", funcName, "0", "one", "two"], + fcall = await client.fcallReadonlyRoute( + funcName, + ["one", "two"], route, ); checkClusterResponse( @@ -659,8 +660,9 @@ describe("GlideClusterClient", () => { await client.functionLoad(newCode, true), ).toEqual(libName); - fcall = await client.customCommand( - ["FCALL", func2Name, "0", "one", "two"], + fcall = await client.fcallRoute( + func2Name, + ["one", "two"], route, ); checkClusterResponse( @@ -669,8 +671,9 @@ describe("GlideClusterClient", () => { (value) => expect(value).toEqual(2), ); - fcall = await client.customCommand( - ["FCALL_RO", func2Name, "0", "one", "two"], + fcall = await client.fcallReadonlyRoute( + func2Name, + ["one", "two"], route, ); checkClusterResponse( diff --git a/node/tests/TestUtilities.ts b/node/tests/TestUtilities.ts index 4a009cef85..e350bef201 100644 --- a/node/tests/TestUtilities.ts +++ b/node/tests/TestUtilities.ts @@ -693,6 +693,10 @@ export async function transactionTest( args.push(libName); baseTransaction.functionLoad(code, true); args.push(libName); + baseTransaction.fcall(funcName, undefined, ["one", "two"]); + args.push("one"); + baseTransaction.fcallReadonly(funcName, undefined, ["one", "two"]); + args.push("one"); baseTransaction.functionDelete(libName); args.push("OK"); baseTransaction.functionFlush(); From 9cf271c04c30ac5e0478006529e9fc77241f1ca6 Mon Sep 17 00:00:00 2001 From: Yi-Pin Chen Date: Wed, 24 Jul 2024 09:55:40 -0700 Subject: [PATCH 2/3] Updated CHANGELOG Signed-off-by: Yi-Pin Chen --- CHANGELOG.md | 1 + node/src/GlideClusterClient.ts | 2 +- node/src/Transaction.ts | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff4afea615..4175ad6af9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * Node: Added FUNCTION LOAD command ([#1969](https://github.com/valkey-io/valkey-glide/pull/1969)) * Node: Added FUNCTION DELETE command ([#1990](https://github.com/valkey-io/valkey-glide/pull/1990)) * Node: Added FUNCTION FLUSH command ([#1984](https://github.com/valkey-io/valkey-glide/pull/1984)) +* Node: Added FCALL and FCALL_RO commands ([#2011](https://github.com/valkey-io/valkey-glide/pull/2011)) * Node: Added ZMPOP command ([#1994](https://github.com/valkey-io/valkey-glide/pull/1994)) #### Fixes diff --git a/node/src/GlideClusterClient.ts b/node/src/GlideClusterClient.ts index 7a94cd3514..c7819b5064 100644 --- a/node/src/GlideClusterClient.ts +++ b/node/src/GlideClusterClient.ts @@ -706,7 +706,7 @@ export class GlideClusterClient extends BaseClient { * * @example * ```typescript - * const response = await client.fcallReadOnly("Deep_Thought", ["Answer", "to", "the", "Ultimate", + * const response = await client.fcallReadonlyRoute("Deep_Thought", ["Answer", "to", "the", "Ultimate", * "Question", "of", "Life,", "the", "Universe,", "and", "Everything"], "randomNode"); * console.log(response); // Output: 42 # The return value on the function that was execute. * ``` diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index 0d242d91ab..db48e03b9d 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -5,6 +5,7 @@ import { AggregationType, ExpireOptions, + GeoUnit, InfoOptions, InsertPosition, KeyWeight, @@ -144,7 +145,6 @@ import { createZRevRank, createZRevRankWithScore, createZScore, - GeoUnit, } from "./Commands"; import { command_request } from "./ProtobufMessage"; import { BitOffsetOptions } from "./commands/BitOffsetOptions"; @@ -1864,7 +1864,7 @@ export class BaseTransaction> { * since Valkey version 7.0.0. * * @param func - The function name. - * @param keys - A list of keys accessed by the function. To ensure the correct execution of functions, + * @param keys - A list of `keys` accessed by the function. To ensure the correct execution of functions, * all names of keys that a function accesses must be explicitly provided as `keys`. * @param args - A list of `function` arguments and it should not represent names of keys. * @@ -1882,7 +1882,7 @@ export class BaseTransaction> { * since Valkey version 7.0.0. * * @param func - The function name. - * @param keys - A list of keys accessed by the function. To ensure the correct execution of functions, + * @param keys - A list of `keys` accessed by the function. To ensure the correct execution of functions, * all names of keys that a function accesses must be explicitly provided as `keys`. * @param args - A list of `function` arguments and it should not represent names of keys. * From 79df75901ff7e7b4c67f1fd15fc66c51e110cd4c Mon Sep 17 00:00:00 2001 From: Yi-Pin Chen Date: Wed, 24 Jul 2024 14:57:02 -0700 Subject: [PATCH 3/3] Addressed review comments Signed-off-by: Yi-Pin Chen --- node/src/BaseClient.ts | 16 +++++------ node/src/Commands.ts | 40 ++++++--------------------- node/src/GlideClusterClient.ts | 20 +++++++------- node/src/Transaction.ts | 8 +++--- node/tests/RedisClient.test.ts | 14 +++------- node/tests/RedisClusterClient.test.ts | 8 +++--- node/tests/TestUtilities.ts | 4 +-- 7 files changed, 40 insertions(+), 70 deletions(-) diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index d5d43709e3..2f3b00c40e 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -3342,20 +3342,20 @@ export class BaseClient { * @remarks When in cluster mode, all `keys` must map to the same hash slot. * @param func - The function name. * @param keys - A list of `keys` accessed by the function. To ensure the correct execution of functions, - * all names of keys that a function accesses must be explicitly provided as `keys`. + * all names of keys that a function accesses must be explicitly provided as `keys`. * @param args - A list of `function` arguments and it should not represent names of keys. * @returns The invoked function's return value. * * @example * ```typescript - * const response = await client.fcall("Deep_Thought"); + * const response = await client.fcall("Deep_Thought", [], []); * console.log(response); // Output: Returns the function's return value. * ``` */ public fcall( func: string, - keys?: string[], - args?: string[], + keys: string[], + args: string[], ): Promise { return this.createWritePromise(createFCall(func, keys, args)); } @@ -3370,7 +3370,7 @@ export class BaseClient { * @remarks When in cluster mode, all `keys` must map to the same hash slot. * @param func - The function name. * @param keys - A list of `keys` accessed by the function. To ensure the correct execution of functions, - * all names of keys that a function accesses must be explicitly provided as `keys`. + * all names of keys that a function accesses must be explicitly provided as `keys`. * @param args - A list of `function` arguments and it should not represent names of keys. * @returns The invoked function's return value. * @@ -3378,13 +3378,13 @@ export class BaseClient { * ```typescript * const response = await client.fcallReadOnly("Deep_Thought", ["key1"], ["Answer", "to", "the", * "Ultimate", "Question", "of", "Life,", "the", "Universe,", "and", "Everything"]); - * console.log(response); // Output: 42 # The return value on the function that was execute. + * console.log(response); // Output: 42 # The return value on the function that was executed. * ``` */ public fcallReadonly( func: string, - keys?: string[], - args?: string[], + keys: string[], + args: string[], ): Promise { return this.createWritePromise(createFCallReadOnly(func, keys, args)); } diff --git a/node/src/Commands.ts b/node/src/Commands.ts index fe0b2fa50c..4b6fcbb73d 100644 --- a/node/src/Commands.ts +++ b/node/src/Commands.ts @@ -1589,23 +1589,11 @@ export function createBLPop( */ export function createFCall( func: string, - keys?: string[], - args?: string[], + keys: string[], + args: string[], ): command_request.Command { - const params: string[] = []; - params.push(func); - - if (keys !== undefined) { - params.push(keys.length.toString()); - params.push(...keys); - } else { - params.push("0"); - } - - if (args !== undefined) { - params.push(...args); - } - + let params: string[] = []; + params = params.concat(func, keys.length.toString(), keys, args); return createCommand(RequestType.FCall, params); } @@ -1614,23 +1602,11 @@ export function createFCall( */ export function createFCallReadOnly( func: string, - keys?: string[], - args?: string[], + keys: string[], + args: string[], ): command_request.Command { - const params: string[] = []; - params.push(func); - - if (keys !== undefined) { - params.push(keys.length.toString()); - params.push(...keys); - } else { - params.push("0"); - } - - if (args !== undefined) { - params.push(...args); - } - + let params: string[] = []; + params = params.concat(func, keys.length.toString(), keys, args); return createCommand(RequestType.FCallReadOnly, params); } diff --git a/node/src/GlideClusterClient.ts b/node/src/GlideClusterClient.ts index c7819b5064..0cddacdb0f 100644 --- a/node/src/GlideClusterClient.ts +++ b/node/src/GlideClusterClient.ts @@ -671,22 +671,22 @@ export class GlideClusterClient extends BaseClient { * @param func - The function name. * @param args - A list of `function` arguments and it should not represent names of keys. * @param route - The command will be routed to a random node, unless `route` is provided, in which - * case the client will route the command to the nodes defined by `route`. + * case the client will route the command to the nodes defined by `route`. * @returns The invoked function's return value. * * @example * ```typescript - * const response = await client.fcallRoute("Deep_Thought", undefined, "randomNode"); + * const response = await client.fcallWithRoute("Deep_Thought", [], "randomNode"); * console.log(response); // Output: Returns the function's return value. * ``` */ - public fcallRoute( + public fcallWithRoute( func: string, - args?: string[], + args: string[], route?: Routes, ): Promise { return this.createWritePromise( - createFCall(func, undefined, args), + createFCall(func, [], args), toProtobufRoute(route), ); } @@ -701,23 +701,23 @@ export class GlideClusterClient extends BaseClient { * @param func - The function name. * @param args - A list of `function` arguments and it should not represent names of keys. * @param route - The command will be routed to a random node, unless `route` is provided, in which - * case the client will route the command to the nodes defined by `route`. + * case the client will route the command to the nodes defined by `route`. * @returns The invoked function's return value. * * @example * ```typescript - * const response = await client.fcallReadonlyRoute("Deep_Thought", ["Answer", "to", "the", "Ultimate", + * const response = await client.fcallReadonlyWithRoute("Deep_Thought", ["Answer", "to", "the", "Ultimate", * "Question", "of", "Life,", "the", "Universe,", "and", "Everything"], "randomNode"); * console.log(response); // Output: 42 # The return value on the function that was execute. * ``` */ - public fcallReadonlyRoute( + public fcallReadonlyWithRoute( func: string, - args?: string[], + args: string[], route?: Routes, ): Promise { return this.createWritePromise( - createFCallReadOnly(func, undefined, args), + createFCallReadOnly(func, [], args), toProtobufRoute(route), ); } diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index db48e03b9d..2cfdaae4dc 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -1865,12 +1865,12 @@ export class BaseTransaction> { * * @param func - The function name. * @param keys - A list of `keys` accessed by the function. To ensure the correct execution of functions, - * all names of keys that a function accesses must be explicitly provided as `keys`. + * all names of keys that a function accesses must be explicitly provided as `keys`. * @param args - A list of `function` arguments and it should not represent names of keys. * * Command Response - The invoked function's return value. */ - public fcall(func: string, keys?: string[], args?: string[]): T { + public fcall(func: string, keys: string[], args: string[]): T { return this.addAndReturn(createFCall(func, keys, args)); } @@ -1883,12 +1883,12 @@ export class BaseTransaction> { * * @param func - The function name. * @param keys - A list of `keys` accessed by the function. To ensure the correct execution of functions, - * all names of keys that a function accesses must be explicitly provided as `keys`. + * all names of keys that a function accesses must be explicitly provided as `keys`. * @param args - A list of `function` arguments and it should not represent names of keys. * * Command Response - The invoked function's return value. */ - public fcallReadonly(func: string, keys?: string[], args?: string[]): T { + public fcallReadonly(func: string, keys: string[], args: string[]): T { return this.addAndReturn(createFCallReadOnly(func, keys, args)); } diff --git a/node/tests/RedisClient.test.ts b/node/tests/RedisClient.test.ts index fe0b78e73f..3a6a83c117 100644 --- a/node/tests/RedisClient.test.ts +++ b/node/tests/RedisClient.test.ts @@ -397,13 +397,10 @@ describe("GlideClient", () => { checkSimple(await client.functionLoad(code)).toEqual(libName); checkSimple( - await client.fcall(funcName, undefined, ["one", "two"]), + await client.fcall(funcName, [], ["one", "two"]), ).toEqual("one"); checkSimple( - await client.fcallReadonly(funcName, undefined, [ - "one", - "two", - ]), + await client.fcallReadonly(funcName, [], ["one", "two"]), ).toEqual("one"); // TODO verify with FUNCTION LIST @@ -433,13 +430,10 @@ describe("GlideClient", () => { ); checkSimple( - await client.fcall(func2Name, undefined, ["one", "two"]), + await client.fcall(func2Name, [], ["one", "two"]), ).toEqual(2); checkSimple( - await client.fcallReadonly(func2Name, undefined, [ - "one", - "two", - ]), + await client.fcallReadonly(func2Name, [], ["one", "two"]), ).toEqual(2); } finally { expect(await client.functionFlush()).toEqual("OK"); diff --git a/node/tests/RedisClusterClient.test.ts b/node/tests/RedisClusterClient.test.ts index fb170a8fbb..064b155a28 100644 --- a/node/tests/RedisClusterClient.test.ts +++ b/node/tests/RedisClusterClient.test.ts @@ -610,7 +610,7 @@ describe("GlideClusterClient", () => { await client.functionLoad(code), ).toEqual(libName); // call functions from that library to confirm that it works - let fcall = await client.fcallRoute( + let fcall = await client.fcallWithRoute( funcName, ["one", "two"], route, @@ -621,7 +621,7 @@ describe("GlideClusterClient", () => { (value) => checkSimple(value).toEqual("one"), ); - fcall = await client.fcallReadonlyRoute( + fcall = await client.fcallReadonlyWithRoute( funcName, ["one", "two"], route, @@ -660,7 +660,7 @@ describe("GlideClusterClient", () => { await client.functionLoad(newCode, true), ).toEqual(libName); - fcall = await client.fcallRoute( + fcall = await client.fcallWithRoute( func2Name, ["one", "two"], route, @@ -671,7 +671,7 @@ describe("GlideClusterClient", () => { (value) => expect(value).toEqual(2), ); - fcall = await client.fcallReadonlyRoute( + fcall = await client.fcallReadonlyWithRoute( func2Name, ["one", "two"], route, diff --git a/node/tests/TestUtilities.ts b/node/tests/TestUtilities.ts index e350bef201..03978c0cb7 100644 --- a/node/tests/TestUtilities.ts +++ b/node/tests/TestUtilities.ts @@ -693,9 +693,9 @@ export async function transactionTest( args.push(libName); baseTransaction.functionLoad(code, true); args.push(libName); - baseTransaction.fcall(funcName, undefined, ["one", "two"]); + baseTransaction.fcall(funcName, [], ["one", "two"]); args.push("one"); - baseTransaction.fcallReadonly(funcName, undefined, ["one", "two"]); + baseTransaction.fcallReadonly(funcName, [], ["one", "two"]); args.push("one"); baseTransaction.functionDelete(libName); args.push("OK");