Skip to content

Commit

Permalink
Fix Circuit Breaker section in JS client docs
Browse files Browse the repository at this point in the history
Fix opensearch-project#823

Signed-off-by: Robert Da Silva <mail@robdasilva.com>
  • Loading branch information
robdasilva committed Jul 21, 2022
1 parent 0b01755 commit 74f80d3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions _clients/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,22 @@ search().catch(console.log);

## Circuit Breaker

The `memoryCircuitBreaker` parameter in the [Cluster Settings API]({{site.url}}{{site.baseurl}}/opensearch/rest-api/cluster-settings/) gives you the ability to reject large query responses where the size of the response could crash OpenSearch Dashboards. To set the Circuit Breaker setting, use the `POST _cluster/settings` API operation on your active JS OpenSearch cluster.
Helper function to check if memory circuit breaker enabled and the response payload is too large to fit into available heap memory.

The `memoryCircuitBreaker` option can be used to prevent errors caused by a response payload being too large to fit into the available heap memory available to the client.

`memoryCircuitBreaker` contains two fields:

- `enabled`: A Boolean used to turn the Circuit Breaker on or off. Defaults to `false`.
- `maxPercentage`: The threshold that determines whether the Circuit Breaker engages. The input range must be between `[0 ,1]`. Any number that exceeds that range will correct to `1.0`.

The following example turns on the Circuit Breaker and sets the maximum percentage of a query response to 80% of the cluster's storage. You can customize this example for use in the `POST _cluster/settings` request body.
The following example instantiates a client with the Circuit Breaker enabled and its threshold set to 80% of the available heap size limit:

```json
memoryCircuitBreaker: {
enabled: true,
maxPercentage: 0.8
}
```
```javascript
var client = new Client({
memoryCircuitBreaker: {
enabled: true,
maxPercentage: 0.8,
},
});
```

0 comments on commit 74f80d3

Please sign in to comment.