MCPcopy
hub / github.com/redis/node-redis / RedisCluster

Class RedisCluster

packages/client/lib/cluster/index.ts:168–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166type NamespaceProxyCluster = { _self: ProxyCluster };
167
168export default class RedisCluster<
169 M extends RedisModules,
170 F extends RedisFunctions,
171 S extends RedisScripts,
172 RESP extends RespVersions,
173 TYPE_MAPPING extends TypeMapping,
174 // POLICIES extends CommandPolicies
175> extends EventEmitter {
176 static #createCommand(command: Command, resp: RespVersions) {
177 const transformReply = getTransformReply(command, resp);
178
179 return async function (this: ProxyCluster, ...args: Array<unknown>) {
180 const parser = new BasicCommandParser(this._self._keyPrefix);
181 command.parseCommand(parser, ...args);
182
183 return this._self._execute(
184 parser.firstKey,
185 command.IS_READ_ONLY,
186 this._commandOptions,
187 (client, opts) => client._executeCommand(command, parser, opts, transformReply)
188 );
189 };
190 }
191
192 static #createModuleCommand(command: Command, resp: RespVersions) {
193 const transformReply = getTransformReply(command, resp);
194
195 return async function (this: NamespaceProxyCluster, ...args: Array<unknown>) {
196 const parser = new BasicCommandParser(this._self._keyPrefix);
197 command.parseCommand(parser, ...args);
198
199 return this._self._execute(
200 parser.firstKey,
201 command.IS_READ_ONLY,
202 this._self._commandOptions,
203 (client, opts) => client._executeCommand(command, parser, opts, transformReply)
204 );
205 };
206 }
207
208 static #createFunctionCommand(name: string, fn: RedisFunction, resp: RespVersions) {
209 const prefix = functionArgumentsPrefix(name, fn);
210 const transformReply = getTransformReply(fn, resp);
211
212 return async function (this: NamespaceProxyCluster, ...args: Array<unknown>) {
213 const parser = new BasicCommandParser(this._self._keyPrefix);
214 parser.push(...prefix);
215 fn.parseCommand(parser, ...args);
216
217 return this._self._execute(
218 parser.firstKey,
219 fn.IS_READ_ONLY,
220 this._self._commandOptions,
221 (client, opts) => client._executeCommand(fn, parser, opts, transformReply)
222 );
223 };
224 }
225

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected