On this page

Extends: undici.Dispatcher

A pool of Client instances connected to the same upstream target.

Requests are not guaranteed to be dispatched in order of invocation.

new Pool(url, options?): void

Arguments:

  • url URL | string - It should only include the protocol, hostname, and port.
  • options PoolOptions (optional)

Extends: ClientOptions

  • factory (origin: URL, opts: Object) => Dispatcher - Default: (origin, opts) => new Client(origin, opts)
  • connections number | null (optional) - Default: null - The number of Client instances to create. When set to null, the Pool instance will create an unlimited amount of Client instances.
  • clientTtl number | null (optional) - Default: null - The amount of time before a Client instance is removed from the Pool and closed. When set to null, Client instances will not be removed or closed based on age.
Note

Pool inherits all ClientOptions, including allowH2 (default true) and maxConcurrentStreams (default 100). With the unlimited default of connections, Pool will open a new Client — and therefore a new TCP/TLS socket — per concurrent dispatch, which defeats HTTP/2 multiplexing on a shared session. To benefit from h2 multiplexing on a single session, cap connections (e.g. connections: 1) so that concurrent requests share a session up to maxConcurrentStreams.

Implements Client.closed

Implements Client.destroyed

Returns PoolStats instance for this pool.

Pool.close(callback?): void

Implements Dispatcher.close([callback]).

Pool.destroy(error?, callback?): void

Implements Dispatcher.destroy([error, callback]).

Pool.connect(options, callback?): void

See Dispatcher.connect(options[, callback]).

Pool.dispatch(options, handler): void

Implements Dispatcher.dispatch(options, handler).

Pool.pipeline(options, handler): void

See Dispatcher.pipeline(options, handler).

Pool.request(options, callback?): void

See Dispatcher.request(options [, callback]).

Pool.stream(options, factory, callback?): void

See Dispatcher.stream(options, factory[, callback]).

Pool.upgrade(options, callback?): void

See Dispatcher.upgrade(options[, callback]).

See Dispatcher Event: 'connect'.

See Dispatcher Event: 'disconnect'.

See Dispatcher Event: 'drain'.