Class: BalancedAPIRequest

BalancedAPIRequest(limits, tenants)

The BalancedAPIRequest class enriches the functionality of DirectAPIRequest with an efficient load balancing, queuing and request throttling layer that protects the Dynatrace cluster from request overload while ensuring that for each request the best (most available) cluster node is selected to handle that request. Additionally, it provides a simple way to cancel any request if the caller is no longer interested in the response.

Constructor

new BalancedAPIRequest(limits, tenants)

Creates a pool of connections to reach multiple tenants and clusters.

Parameters:
Name Type Description
limits object

Default values for retryLimit, retryAfter and timeout.

tenants Array.<TenantConfig>

The configurations for the tenants.

Source:

Methods

(async) fetch(options, onDoneopt) → {CancellableEventEmitter|CancellablePromise}

Note that in this class the RequestOptions object also supports the noQueue property.

Required properties in the RequestOptions object (unless an alias is used - see below):

  • url: URL relative to the tenant. Ex.: '/api/v2/entities'.
  • tenant: Name of the Dynatrace tenant. Ex.: 'PROD'.

For convenience aliases have been provided for the following request methods:

  • get(url, options[, onDone])
  • delete(url, options[, onDone])
  • post(url, data, options[, onDone])
  • put(url, data, options[, onDone])
Parameters:
Name Type Attributes Description
options RequestOptions

The request options, Axios-style.

onDone RequestCallback <optional>

Callback that handles the result (alternative to using a Promise).

Source:
Returns:

If onDone is provided, this method returns a CancellableEventEmitter. Else, this method returns a CancellablePromise.

Type
CancellableEventEmitter | CancellablePromise

getHealthMetrics(frequencyopt, callbackopt)

Report the health of the connection pool. If no parameters are specified, the health report will be returned. If both parameters are specified, the callback will be called with the health report as its only parameter, per the specified frequency.

Parameters:
Name Type Attributes Description
frequency number <optional>

The requency with which the health of the connection pool should be reported.

callback function <optional>

The function that consumes the health report.

Source:

restart()

Cancel all running and/or queued requests and reset the connection pool.

Source:

shutdown()

Cancel all running and/or queued requests and delete the connection pool.

Source: