On this page

Extends: undici.Dispatcher

A pool of Pool instances connected to multiple upstreams.

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

new BalancedPool(upstreams , options?): void

Arguments:

  • upstreams URL | string | string[] - It should only include the protocol, hostname, and port.
  • options BalancedPoolOptions (optional)

Extends: PoolOptions

  • factory (origin: URL, opts: Object) => Dispatcher - Default: (origin, opts) => new Pool(origin, opts)

The PoolOptions are passed to each of the Pool instances being created.

Returns an array of upstreams that were previously added.

Implements Client.closed

Implements Client.destroyed

Returns PoolStats instance for this pool.

BalancedPool.addUpstream(upstream): void

Add an upstream.

Arguments:

  • upstream string - It should only include the protocol, hostname, and port.
BalancedPool.removeUpstream(upstream): void

Removes an upstream that was previously added.

BalancedPool.close(callback?): void

Implements Dispatcher.close([callback]).

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

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

BalancedPool.connect(options, callback?): void

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

BalancedPool.dispatch(options, handlers): void

Implements Dispatcher.dispatch(options, handlers).

BalancedPool.pipeline(options, handler): void

See Dispatcher.pipeline(options, handler).

BalancedPool.request(options, callback?): void

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

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

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

BalancedPool.upgrade(options, callback?): void

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

See Dispatcher Event: 'connect'.

See Dispatcher Event: 'disconnect'.

See Dispatcher Event: 'drain'.