From 94af8c8666d8e543a5fb5e3da7cbe5b395985524 Mon Sep 17 00:00:00 2001 From: Shaya Potter Date: Tue, 30 Jan 2024 19:27:44 +0200 Subject: [PATCH] just a hack for testing pass through --- packages/client/lib/RESP/types.ts | 1 + packages/client/lib/client/pool.ts | 10 ++++++++-- packages/client/lib/commands/GET.ts | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/client/lib/RESP/types.ts b/packages/client/lib/RESP/types.ts index 3869eede67..a59e961892 100644 --- a/packages/client/lib/RESP/types.ts +++ b/packages/client/lib/RESP/types.ts @@ -269,6 +269,7 @@ export interface CacheInfo { } export type Command = { + name?: () => string; FIRST_KEY_INDEX?: number | ((this: void, ...args: Array) => RedisArgument | undefined); IS_READ_ONLY?: boolean; /** diff --git a/packages/client/lib/client/pool.ts b/packages/client/lib/client/pool.ts index 2efdbcaab3..07e9b95017 100644 --- a/packages/client/lib/client/pool.ts +++ b/packages/client/lib/client/pool.ts @@ -63,13 +63,19 @@ export class RedisClientPool< RESP extends RespVersions = 2, TYPE_MAPPING extends TypeMapping = {} > extends EventEmitter { - // TODO: for CSC will have to be modified, to directly call function on underlying chosen client static #createCommand(command: Command, resp: RespVersions) { + // TODO: for CSC will have to be modified, to directly call function on underlying chosen client + // this is .name() is just a hack for now. + const name = command.name?.(); const transformReply = getTransformReply(command, resp); return async function (this: ProxyPool, ...args: Array) { + if (name) { + return this.execute((client => { return client[name](...args)})) + } + const redisArgs = command.transformArguments(...args), reply = await this.sendCommand(redisArgs, this._commandOptions); - return transformReply ? + return transformReply ? transformReply(reply, redisArgs.preserve) : reply; }; diff --git a/packages/client/lib/commands/GET.ts b/packages/client/lib/commands/GET.ts index 9f0979cd64..c2cf5e4912 100644 --- a/packages/client/lib/commands/GET.ts +++ b/packages/client/lib/commands/GET.ts @@ -1,6 +1,7 @@ import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types'; export default { + name: () => { return "GET" }, FIRST_KEY_INDEX: 1, IS_READ_ONLY: true, transformArguments(key: RedisArgument) {