diff --git a/_clients/javascript.md b/_clients/javascript.md index 4b10bb260c..cc57330297 100644 --- a/_clients/javascript.md +++ b/_clients/javascript.md @@ -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 -} -``` \ No newline at end of file +```javascript +var client = new Client({ + memoryCircuitBreaker: { + enabled: true, + maxPercentage: 0.8, + }, +}); +```