dynatrace-api-balancer
Version:
A wrapper around Axios that balances and throttles requests across tenants, clusters and cluster nodes.
2,101 lines (680 loc) • 37.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Global</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2></h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Type Definitions</h3>
<h4 class="name" id="RequestCallback"><span class="type-signature"></span>RequestCallback<span class="signature">(error, data)</span><span class="type-signature"></span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type"><a href="global.html#RequestError">RequestError</a></span>
</td>
<td class="description last"><p>The error if the request could not be fulfilled.</p></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>The Dynatrace API's response, as a parsed JSON object, if the request was succesful.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line90">line 90</a>
</li></ul></dd>
</dl>
<h4 class="name" id="RequestError">RequestError</h4>
<div class="description">
<p>A unified error object that consolidates the various types of errors that may happen
while initializating a request, issuing it, and processing its response.</p>
</div>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>status</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>An internal error code (string) or an HTTP status code (number).</p></td>
</tr>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Human-readble description of the error.</p></td>
</tr>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Original (relative) URL.</p></td>
</tr>
<tr>
<td class="name"><code>baseURL</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Effective base URL.</p></td>
</tr>
<tr>
<td class="name"><code>method</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Request method used.</p></td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
null
</td>
<td class="description last"><p>Query parameters passed.</p></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
null
</td>
<td class="description last"><p>Data sent in the request body.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line74">line 74</a>
</li></ul></dd>
</dl>
<h4 class="name" id="RequestOptions">RequestOptions</h4>
<div class="description">
<p>The <code>options</code> object support all options supported by <a href="https://axios-http.com/docs/req_config" title="Axios">Axios</a>,
except where otherwise noted below. This implementation also adds a couple of additional options (i.e. <code>tenant</code>,
<code>noQueue</code> and <code>maxRetries</code>) that are specific to this implementation.
Note that either a <code>tenant</code> or a <code>baseURL</code> must be provided, but not both.</p>
</div>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>URL relative to the <code>baseURL</code> or the <code>tenant</code>. Ex.: <code>'/api/v2/entities'</code>.</p></td>
</tr>
<tr>
<td class="name"><code>method</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
'get'
</td>
<td class="description last"><p>Request method (<code>'get'</code>, <code>'put'</code>, <code>'post'</code>, <code>'delete'</code>).</p></td>
</tr>
<tr>
<td class="name"><code>tenant</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Name of the Dynatrace tenant (<a href="BalancedAPIRequest.html"><code>BalancedAPIRequest</code></a> only - <strong>not an Axios property</strong>). Ex.: <code>'PROD'</code>.</p></td>
</tr>
<tr>
<td class="name"><code>baseURL</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>URL of the Dynatrace tenant (<a href="DirectAPIRequest.html"><code>DirectAPIRequest</code></a> only). Ex.: <code>'https://abc12345.live.dynatrace.com'</code>.</p></td>
</tr>
<tr>
<td class="name"><code>headers</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>Plain <code>object</code> containing the headers to be set in the request. Ex.: <code>{ 'Authorization': 'token XYZ' }</code>.</p></td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>URL parameters to be sent with the request. Must be a plain <code>object</code> or a <code>URLSearchParams</code> object. Ex.: <code>{ ID: 12345 }</code>.</p></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>Must be of one of the following types: <code>string</code>, <code>object</code>, <code>ArrayBuffer</code>, <code>ArrayBufferView</code>, <code>URLSearchParams</code>, <code>Stream</code>, <code>Buffer</code>. Ex.: <code>{ firstName: 'Bart' }</code>.</p></td>
</tr>
<tr>
<td class="name"><code>noQueue</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
false
</td>
<td class="description last"><p>Specifies whether the request should be rejected if due to throttling it cannot immediately be issued (<a href="BalancedAPIRequest.html"><code>BalancedAPIRequest</code></a> only - <strong>not an Axios property</strong>).</p></td>
</tr>
<tr>
<td class="name"><code>timeout</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
5000
</td>
<td class="description last"><p>Number of milliseconds before the request times out. If the request takes longer than <code>timeout</code>, it will be aborted (if it has been issued already) or cancelled (if it is still waiting in a queue).</p></td>
</tr>
<tr>
<td class="name"><code>retryAfter</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>Number of milliseconds to wait before trying again after a 429 or 503 status is received and the response does not contain a 'Retry-After' header. If not provided, the default from the constructor is used.</p></td>
</tr>
<tr>
<td class="name"><code>maxRedirects</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
5
</td>
<td class="description last"><p>Maximum number of redirects to follow. If set to 0, no redirects will be followed.</p></td>
</tr>
<tr>
<td class="name"><code>maxRetries</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
3
</td>
<td class="description last"><p>Maximum number of retries allowed if a potentially transient error is encountered (<strong>not an Axios property</strong>).</p></td>
</tr>
<tr>
<td class="name"><code>maxBodyLength</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
2000
</td>
<td class="description last"><p>Maximum size of the http request content in bytes.</p></td>
</tr>
<tr>
<td class="name"><code>maxContentLength</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
2000
</td>
<td class="description last"><p>Maximum size of the http response content in bytes.</p></td>
</tr>
<tr>
<td class="name"><code>validateStatus</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p><strong>IGNORED</strong> This parameter is set by <a href="BalancedAPIRequest.html"><code>BalancedAPIRequest</code></a> and <a href="DirectAPIRequest.html"><code>DirectAPIRequest</code></a> internally.</p></td>
</tr>
<tr>
<td class="name"><code>responseType</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
'json'
</td>
<td class="description last"><p>Specifies the type of data that the server will respond with. Options are: <code>'arraybuffer'</code>, <code>'document'</code>, <code>'json'</code>, <code>'text'</code>, <code>'stream'</code>. <strong>Note</strong>: The automatic paging support only works then this value is set to <code>'json'</code>.</p></td>
</tr>
<tr>
<td class="name"><code>withCredentials</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
false
</td>
<td class="description last"><p>Specifies whether or not cross-site Access-Control requests should be made using credentials.</p></td>
</tr>
<tr>
<td class="name"><code>responseEncoding</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
'utf8'
</td>
<td class="description last"><p>Encoding to use for decoding responses. Note: Ignored when <code>responseType</code> is <code>'stream'</code>.</p></td>
</tr>
<tr>
<td class="name"><code>cancelToken</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>Specifies a cancel token that can be used to cancel the request. See Axios documentation for details. Note that <a href="BalancedAPIRequest.html"><code>BalancedAPIRequest</code></a> sets this property to create and return a <a href="CancellablePromise.html"><code>CancellablePromise</code></a> or a <a href="CancellableEventEmitter.html"><code>CancellableEventEmitter</code></a> through which requests can be cancelled.</p></td>
</tr>
<tr>
<td class="name"><code>socketPath</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>See Axios documentation.</p></td>
</tr>
<tr>
<td class="name"><code>proxy</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>See Axios documentation.</p></td>
</tr>
<tr>
<td class="name"><code>httpAgent</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>See Axios documentation.</p></td>
</tr>
<tr>
<td class="name"><code>httpsAgent</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>See Axios documentation.</p></td>
</tr>
<tr>
<td class="name"><code>decompress</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
true
</td>
<td class="description last"><p>Specifies whether or not the response body should be decompressed automatically. If set to <code>true</code> will also remove the <code>'content-encoding'</code> header from the response objects of all decompressed responses. <strong>Note</strong>: The automatic paging support only works then this value is set to <code>true</code>.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line38">line 38</a>
</li></ul></dd>
</dl>
<h4 class="name" id="TenantConfig">TenantConfig</h4>
<div class="description">
<p>Represents the configuration for a tenant.</p>
</div>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Name of tenant as used in the <code>tenant</code> property of <a href="global.html#RequestOptions"><code>RequestOptions</code></a>.</p></td>
</tr>
<tr>
<td class="name"><code>host</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The address of the tenant. Either this or the <code>hosts</code> property must be present.</p></td>
</tr>
<tr>
<td class="name"><code>hosts</code></td>
<td class="type">
<span class="param-type">Array.<string></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>A list of addresses of nodes at which the tenant can be reached. This is
typically a subset of cluster nodes (for Managed Clusters).</p></td>
</tr>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>If the nodes(s) are of a Managed Cluster, this is the environment URL.
Ex.: /e/123-456-345</p></td>
</tr>
<tr>
<td class="name"><code>token</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The Dynatrace API token to be used to execute the requests. The permissions
this token should represent depends on the APIs that are permitted to be used.</p></td>
</tr>
<tr>
<td class="name"><code>maxRetries</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
3
</td>
<td class="description last"><p>Maximum number of retries before reporting an error. Note that<br>
retry attempts will stop once the 'timeout' value gets exceeded.</p></td>
</tr>
<tr>
<td class="name"><code>reqRateLimit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
200
</td>
<td class="description last"><p>Maximum number of API requests per minute allowed against this tenant.</p></td>
</tr>
<tr>
<td class="name"><code>maxQueueSize</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
1000
</td>
<td class="description last"><p>Maximum length of the queue. The actual size is typically kept in
check by virtue of the request rate limit.</p></td>
</tr>
<tr>
<td class="name"><code>maxQueueTime</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
5000
</td>
<td class="description last"><p>Maximum number of milliseconds a request may be queued. A request will
be cancelled with 408 status if it stays queued for too long.</p></td>
</tr>
<tr>
<td class="name"><code>requestLimit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
20
</td>
<td class="description last"><p>Maximum allowed number of concurrently active (i.e. issued) requests.</p></td>
</tr>
<tr>
<td class="name"><code>timeout</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
5000
</td>
<td class="description last"><p>Number of milliseconds before a request times out once issued. If a
request takes longer than this value, it will be aborted.</p></td>
</tr>
<tr>
<td class="name"><code>retryAfter</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
5000
</td>
<td class="description last"><p>Number of milliseconds to wait before retrying after a 429 or 503
status where the response does not contain a 'Retry-After' header.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line10">line 10</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BalancedAPIRequest.html">BalancedAPIRequest</a></li><li><a href="CancellableEventEmitter.html">CancellableEventEmitter</a></li><li><a href="CancellablePromise.html">CancellablePromise</a></li><li><a href="DirectAPIRequest.html">DirectAPIRequest</a></li><li><a href="Throttle.html">Throttle</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Sun Dec 19 2021 10:28:39 GMT-0600 (Central Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>