MCPcopy
hub / github.com/redis/node-redis / #create

Method #create

packages/client/lib/client/pool.ts:427–444  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

425 }
426
427 async #create() {
428 const client = this._self.#clientFactory();
429 client._setIdentity(ClientRole.POOL_MEMBER, this._self.#identity.id);
430 client.on('error', (err: Error) => this.emit('error', err));
431 // Track the client as "in use" during connect so it counts toward capacity.
432 // If we waited to add it until after connect, the pool would think it doesn't
433 // exist yet and could spin up extra clients when multiple tasks queue up.
434 const node = this._self.#clientsInUse.push(client);
435
436 try {
437 await client.connect();
438 } catch (err) {
439 this._self.#clientsInUse.remove(node);
440 throw err;
441 }
442
443 this._self.#returnClient(node);
444 }
445
446 execute<T>(fn: PoolTask<M, F, S, RESP, TYPE_MAPPING, T>) {
447 return new Promise<Awaited<T>>((resolve, reject) => {

Callers 2

connectMethod · 0.80
executeMethod · 0.80

Calls 5

_setIdentityMethod · 0.80
#returnClientMethod · 0.80
pushMethod · 0.45
connectMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected