/** * Get the associated circuit breaking rule. * * @return associated circuit breaking rule * 获取熔断规则 */ DegradeRule getRule();
/** * Acquires permission of an invocation only if it is available at the time of invoking. * * @param context context of current invocation * @return {@code true} if permission was acquired and {@code false} otherwise * 判断是否需要降级 返回值为false开启降级 */ booleantryPass(Context context);
/** * Get current state of the circuit breaker. * * @return current state of the circuit breaker * 当前熔断器状态 */ State currentState();
/** * <p>Record a completed request with the context and handle state transformation of the circuit breaker.</p> * <p>Called when a <strong>passed</strong> invocation finished.</p> * * @param context context of current invocation * 回调方法 当请求通过后触发 */ voidonRequestComplete(Context context);
/** * Circuit breaker state. * 三种熔断器状态: * OPEN开启 * HALF_OPEN半开启 * CLOSED关闭 */ enumState { /** * In {@code OPEN} state, all requests will be rejected until the next recovery time point. */ OPEN, /** * In {@code HALF_OPEN} state, the circuit breaker will allow a "probe" invocation. * If the invocation is abnormal according to the strategy (e.g. it's slow), the circuit breaker * will re-transform to the {@code OPEN} state and wait for the next recovery time point; * otherwise the resource will be regarded as "recovered" and the circuit breaker * will cease cutting off requests and transform to {@code CLOSED} state. */ HALF_OPEN, /** * In {@code CLOSED} state, all requests are permitted. When current metric value exceeds the threshold, * the circuit breaker will transform to {@code OPEN} state. */ CLOSED } }