MCPcopy Create free account
hub / github.com/denodrivers/postgres / #initialize

Method #initialize

pool.ts:190–212  ·  view source on GitHub ↗

* Initialization will create all pool clients instances by default * * If the pool is lazily initialized, the clients will connect when they * are requested by the user, otherwise they will all connect on initialization

()

Source from the content-addressed store, hash-verified

188 * are requested by the user, otherwise they will all connect on initialization
189 */
190 async #initialize() {
191 const initialized = this.#lazy ? 0 : this.#size;
192 const clients = Array.from({ length: this.#size }, async (_e, index) => {
193 const client: PoolClient = new PoolClient(
194 this.#connection_params,
195 () => this.#available_connections!.push(client),
196 );
197
198 if (index < initialized) {
199 await client.connect();
200 }
201
202 return client;
203 });
204
205 this.#available_connections = new DeferredAccessStack(
206 await Promise.all(clients),
207 (client) => client.connect(),
208 (client) => client.connected,
209 );
210
211 this.#ended = false;
212 }
213 /**
214 * This will return the number of initialized clients in the pool
215 */

Callers 2

constructorMethod · 0.95
connectMethod · 0.95

Calls 2

connectMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected