Pool
The Pool maintains a list available Influx hosts and dispatches requests to them. If there are errors connecting to hosts, it will disable that host for a period of time.
Constructor Summary
Public Constructor | ||
public |
constructor(options: IPoolOptions) Creates a new Pool instance. |
Method Summary
Public Methods | ||
public |
addHost(url: *, options: {}): * Inserts a new host to the pool. |
|
public |
discard(options: *): * Makes a request and discards any response body it receives. |
|
public |
getHostsAvailable(): Host[] Returns a list of currently active hosts. |
|
public |
getHostsDisabled(): Host[] Returns a list of hosts that are currently disabled due to network errors. |
|
public |
Returns true if there's any host available to by queried. |
|
public |
json(options: *): * Makes a request and calls back with the response, parsed as JSON. |
|
public |
Ping sends out a request to all available Influx servers, reporting on their response time and version number. |
|
public |
stream(options: *, callback: *): * Makes a request and calls back with the IncomingMessage stream, if possible. |
|
public |
text(options: *): * Makes a request and resolves with the plain text response, if possible. |
Private Methods | ||
private |
_disableHost(host: *) Disables the provided host, removing it from the query pool. |
|
private |
_enableHost(host: Host) Re-enables the provided host, returning it to the pool to query. |
|
private |
_getHost(): Host Returns the next available host for querying. |
Public Constructors
public constructor(options: IPoolOptions) source
Creates a new Pool instance.
Params:
Name | Type | Attribute | Description |
options | IPoolOptions |
Public Methods
public addHost(url: *, options: {}): * source
Inserts a new host to the pool.
Params:
Name | Type | Attribute | Description |
url | * | ||
options | {} |
|
Return:
* |
public discard(options: *): * source
Makes a request and discards any response body it receives. An error is returned on a non-2xx status code.
Params:
Name | Type | Attribute | Description |
options | * |
Return:
* |
public getHostsDisabled(): Host[] source
Returns a list of hosts that are currently disabled due to network errors.
Return:
Host[] |
public json(options: *): * source
Makes a request and calls back with the response, parsed as JSON. An error is returned on a non-2xx status code or on a parsing exception.
Params:
Name | Type | Attribute | Description |
options | * |
Return:
* |
public ping(timeout: *, path: string, auth: *): * source
Ping sends out a request to all available Influx servers, reporting on their response time and version number.
Params:
Name | Type | Attribute | Description |
timeout | * | ||
path | string |
|
|
auth | * |
|
Return:
* |
public stream(options: *, callback: *): * source
Makes a request and calls back with the IncomingMessage stream, if possible. An error is returned on a non-2xx status code.
Params:
Name | Type | Attribute | Description |
options | * | ||
callback | * |
Return:
* |
public text(options: *): * source
Makes a request and resolves with the plain text response, if possible. An error is raised on a non-2xx status code.
Params:
Name | Type | Attribute | Description |
options | * |
Return:
* |
Private Methods
private _disableHost(host: *) source
Disables the provided host, removing it from the query pool. It will be re-enabled after a backoff interval
Params:
Name | Type | Attribute | Description |
host | * |
private _enableHost(host: Host) source
Re-enables the provided host, returning it to the pool to query.
Params:
Name | Type | Attribute | Description |
host | Host |