11cb0ef41Sopenharmony_ci# Class: BalancedPool
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciExtends: `undici.Dispatcher`
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciA pool of [Pool](Pool.md) instances connected to multiple upstreams.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciRequests are not guaranteed to be dispatched in order of invocation.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci## `new BalancedPool(upstreams [, options])`
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciArguments:
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci* **upstreams** `URL | string | string[]` - It should only include the **protocol, hostname, and port**.
141cb0ef41Sopenharmony_ci* **options** `BalancedPoolOptions` (optional)
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci### Parameter: `BalancedPoolOptions`
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciExtends: [`PoolOptions`](Pool.md#parameter-pooloptions)
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci* **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciThe `PoolOptions` are passed to each of the `Pool` instances being created.
231cb0ef41Sopenharmony_ci## Instance Properties
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci### `BalancedPool.upstreams`
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciReturns an array of upstreams that were previously added.
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci### `BalancedPool.closed`
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciImplements [Client.closed](Client.md#clientclosed)
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci### `BalancedPool.destroyed`
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ciImplements [Client.destroyed](Client.md#clientdestroyed)
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci### `Pool.stats`
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ciReturns [`PoolStats`](PoolStats.md) instance for this pool.
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci## Instance Methods
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ci### `BalancedPool.addUpstream(upstream)`
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ciAdd an upstream.
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ciArguments:
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci* **upstream** `string` - It should only include the **protocol, hostname, and port**.
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci### `BalancedPool.removeUpstream(upstream)`
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ciRemoves an upstream that was previously addded.
541cb0ef41Sopenharmony_ci
551cb0ef41Sopenharmony_ci### `BalancedPool.close([callback])`
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ciImplements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci### `BalancedPool.destroy([error, callback])`
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ciImplements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
621cb0ef41Sopenharmony_ci
631cb0ef41Sopenharmony_ci### `BalancedPool.connect(options[, callback])`
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ciSee [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
661cb0ef41Sopenharmony_ci
671cb0ef41Sopenharmony_ci### `BalancedPool.dispatch(options, handlers)`
681cb0ef41Sopenharmony_ci
691cb0ef41Sopenharmony_ciImplements [`Dispatcher.dispatch(options, handlers)`](Dispatcher.md#dispatcherdispatchoptions-handler).
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_ci### `BalancedPool.pipeline(options, handler)`
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ciSee [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ci### `BalancedPool.request(options[, callback])`
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_ciSee [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
781cb0ef41Sopenharmony_ci
791cb0ef41Sopenharmony_ci### `BalancedPool.stream(options, factory[, callback])`
801cb0ef41Sopenharmony_ci
811cb0ef41Sopenharmony_ciSee [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_ci### `BalancedPool.upgrade(options[, callback])`
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_ciSee [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
861cb0ef41Sopenharmony_ci
871cb0ef41Sopenharmony_ci## Instance Events
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ci### Event: `'connect'`
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_ciSee [Dispatcher Event: `'connect'`](Dispatcher.md#event-connect).
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci### Event: `'disconnect'`
941cb0ef41Sopenharmony_ci
951cb0ef41Sopenharmony_ciSee [Dispatcher Event: `'disconnect'`](Dispatcher.md#event-disconnect).
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci### Event: `'drain'`
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ciSee [Dispatcher Event: `'drain'`](Dispatcher.md#event-drain).
100