1 | # Class: Pool
|
---|
2 |
|
---|
3 | Extends: `undici.Dispatcher`
|
---|
4 |
|
---|
5 | A pool of [Client](Client.md) instances connected to the same upstream target.
|
---|
6 |
|
---|
7 | Requests are not guaranteed to be dispatched in order of invocation.
|
---|
8 |
|
---|
9 | ## `new Pool(url[, options])`
|
---|
10 |
|
---|
11 | Arguments:
|
---|
12 |
|
---|
13 | * **url** `URL | string` - It should only include the **protocol, hostname, and port**.
|
---|
14 | * **options** `PoolOptions` (optional)
|
---|
15 |
|
---|
16 | ### Parameter: `PoolOptions`
|
---|
17 |
|
---|
18 | Extends: [`ClientOptions`](Client.md#parameter-clientoptions)
|
---|
19 |
|
---|
20 | * **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Client(origin, opts)`
|
---|
21 | * **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.
|
---|
22 | * **interceptors** `{ Pool: DispatchInterceptor[] } }` - Default: `{ Pool: [] }` - A list of interceptors that are applied to the dispatch method. Additional logic can be applied (such as, but not limited to: 302 status code handling, authentication, cookies, compression and caching).
|
---|
23 |
|
---|
24 | ## Instance Properties
|
---|
25 |
|
---|
26 | ### `Pool.closed`
|
---|
27 |
|
---|
28 | Implements [Client.closed](Client.md#clientclosed)
|
---|
29 |
|
---|
30 | ### `Pool.destroyed`
|
---|
31 |
|
---|
32 | Implements [Client.destroyed](Client.md#clientdestroyed)
|
---|
33 |
|
---|
34 | ### `Pool.stats`
|
---|
35 |
|
---|
36 | Returns [`PoolStats`](PoolStats.md) instance for this pool.
|
---|
37 |
|
---|
38 | ## Instance Methods
|
---|
39 |
|
---|
40 | ### `Pool.close([callback])`
|
---|
41 |
|
---|
42 | Implements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
|
---|
43 |
|
---|
44 | ### `Pool.destroy([error, callback])`
|
---|
45 |
|
---|
46 | Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
---|
47 |
|
---|
48 | ### `Pool.connect(options[, callback])`
|
---|
49 |
|
---|
50 | See [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
|
---|
51 |
|
---|
52 | ### `Pool.dispatch(options, handler)`
|
---|
53 |
|
---|
54 | Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
---|
55 |
|
---|
56 | ### `Pool.pipeline(options, handler)`
|
---|
57 |
|
---|
58 | See [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
|
---|
59 |
|
---|
60 | ### `Pool.request(options[, callback])`
|
---|
61 |
|
---|
62 | See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
---|
63 |
|
---|
64 | ### `Pool.stream(options, factory[, callback])`
|
---|
65 |
|
---|
66 | See [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
---|
67 |
|
---|
68 | ### `Pool.upgrade(options[, callback])`
|
---|
69 |
|
---|
70 | See [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
|
---|
71 |
|
---|
72 | ## Instance Events
|
---|
73 |
|
---|
74 | ### Event: `'connect'`
|
---|
75 |
|
---|
76 | See [Dispatcher Event: `'connect'`](Dispatcher.md#event-connect).
|
---|
77 |
|
---|
78 | ### Event: `'disconnect'`
|
---|
79 |
|
---|
80 | See [Dispatcher Event: `'disconnect'`](Dispatcher.md#event-disconnect).
|
---|
81 |
|
---|
82 | ### Event: `'drain'`
|
---|
83 |
|
---|
84 | See [Dispatcher Event: `'drain'`](Dispatcher.md#event-drain).
|
---|