1 | import Client from './client'
|
---|
2 | import TPoolStats from './pool-stats'
|
---|
3 | import { URL } from 'url'
|
---|
4 | import Dispatcher from "./dispatcher";
|
---|
5 |
|
---|
6 | export default Pool
|
---|
7 |
|
---|
8 | type PoolConnectOptions = Omit<Dispatcher.ConnectOptions, "origin">;
|
---|
9 |
|
---|
10 | declare class Pool extends Dispatcher {
|
---|
11 | constructor(url: string | URL, options?: Pool.Options)
|
---|
12 | /** `true` after `pool.close()` has been called. */
|
---|
13 | closed: boolean;
|
---|
14 | /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
|
---|
15 | destroyed: boolean;
|
---|
16 | /** Aggregate stats for a Pool. */
|
---|
17 | readonly stats: TPoolStats;
|
---|
18 |
|
---|
19 | // Override dispatcher APIs.
|
---|
20 | override connect(
|
---|
21 | options: PoolConnectOptions
|
---|
22 | ): Promise<Dispatcher.ConnectData>;
|
---|
23 | override connect(
|
---|
24 | options: PoolConnectOptions,
|
---|
25 | callback: (err: Error | null, data: Dispatcher.ConnectData) => void
|
---|
26 | ): void;
|
---|
27 | }
|
---|
28 |
|
---|
29 | declare namespace Pool {
|
---|
30 | export type PoolStats = TPoolStats;
|
---|
31 | export interface Options extends Client.Options {
|
---|
32 | /** Default: `(origin, opts) => new Client(origin, opts)`. */
|
---|
33 | factory?(origin: URL, opts: object): Dispatcher;
|
---|
34 | /** The max number of clients to create. `null` if no limit. Default `null`. */
|
---|
35 | connections?: number | null;
|
---|
36 |
|
---|
37 | interceptors?: { Pool?: readonly Dispatcher.DispatchInterceptor[] } & Client.Options["interceptors"]
|
---|
38 | }
|
---|
39 | }
|
---|