-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathCircuitBreakerExtension.java
53 lines (48 loc) · 2.21 KB
/
CircuitBreakerExtension.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
package org.opensearch.sdk.api;
import org.opensearch.core.common.breaker.CircuitBreaker;
import org.opensearch.common.settings.Settings;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.core.indices.breaker.CircuitBreakerService;
import org.opensearch.sdk.Extension;
/**
* An extension point for {@link Extension} implementations to add custom circuit breakers
*
*
*/
public interface CircuitBreakerExtension {
/**
* Each of the factory functions are passed to the configured {@link CircuitBreakerService}.
*
* The service then constructs a {@link CircuitBreaker} given the resulting {@link BreakerSettings}.
*
* Custom circuit breakers settings can be found in {@link BreakerSettings}.
* See:
* - limit (example: `breaker.foo.limit`) {@link BreakerSettings#CIRCUIT_BREAKER_LIMIT_SETTING}
* - overhead (example: `breaker.foo.overhead`) {@link BreakerSettings#CIRCUIT_BREAKER_OVERHEAD_SETTING}
* - type (example: `breaker.foo.type`) {@link BreakerSettings#CIRCUIT_BREAKER_TYPE}
*
* The `limit` and `overhead` settings will be dynamically updated in the circuit breaker service iff a {@link BreakerSettings}
* object with the same name is provided at node startup.
* @param settings The constructed {@link Settings} object
* @return The constructed BreakerSetting object
*/
BreakerSettings getCircuitBreaker(Settings settings);
/**
* The passed {@link CircuitBreaker} object is the same one that was constructed by the {@link BreakerSettings}
* provided by {@link CircuitBreakerExtension#getCircuitBreaker(Settings)}.
*
* This reference should never change throughout the lifetime of the node.
*
* @param circuitBreaker The constructed {@link CircuitBreaker} object from the {@link BreakerSettings}
* provided by {@link CircuitBreakerExtension#getCircuitBreaker(Settings)}
*/
void setCircuitBreaker(CircuitBreaker circuitBreaker);
}