Home Manual Reference Source Test
import {Pool} from 'influx/src/pool.js'
public class | source

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(timeout: *, path: string, auth: *): *

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:

NameTypeAttributeDescription
options IPoolOptions

Public Methods

public addHost(url: *, options: {}): * source

Inserts a new host to the pool.

Params:

NameTypeAttributeDescription
url *
options {}
  • optional
  • default: {}

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:

NameTypeAttributeDescription
options *

Return:

*

public getHostsAvailable(): Host[] source

Returns a list of currently active hosts.

Return:

Host[]

public getHostsDisabled(): Host[] source

Returns a list of hosts that are currently disabled due to network errors.

Return:

Host[]

public hostIsAvailable(): Boolean source

Returns true if there's any host available to by queried.

Return:

Boolean

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
timeout *
path string
  • optional
  • default: /ping
auth *
  • optional
  • default: undefined

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
host *

private _enableHost(host: Host) source

Re-enables the provided host, returning it to the pool to query.

Params:

NameTypeAttributeDescription
host Host

private _getHost(): Host source

Returns the next available host for querying.

Return:

Host