Search in sources :

Example 1 with InstancesCircuitBreakTask

use of com.tencent.polaris.circuitbreak.client.task.InstancesCircuitBreakTask in project polaris-java by polarismesh.

the class ServiceCallResultChecker method onServiceCallResult.

@Override
public void onServiceCallResult(InstanceGauge result) {
    if (null == priorityTaskScheduler) {
        return;
    }
    if (CollectionUtils.isEmpty(extensions.getCircuitBreakers())) {
        return;
    }
    InstancesCircuitBreakTask rtTask = null;
    for (CircuitBreaker circuitBreaker : extensions.getCircuitBreakers()) {
        String cbName = circuitBreaker.getName();
        boolean rtLimit = circuitBreaker.stat(result);
        String instId = result.getInstanceId();
        if (rtLimit && StringUtils.isNotEmpty(instId)) {
            ServiceKey svcKey = new ServiceKey(result.getNamespace(), result.getService());
            rtTask = new InstancesCircuitBreakTask(svcKey, cbName, null, instId, extensions, InstancesCircuitBreakTask.TaskPriority.HIGH);
            break;
        }
    }
    if (null == rtTask) {
        return;
    }
    priorityTaskScheduler.addCircuitBreakTask(rtTask);
}
Also used : CircuitBreaker(com.tencent.polaris.api.plugin.circuitbreaker.CircuitBreaker) ServiceKey(com.tencent.polaris.api.pojo.ServiceKey) InstancesCircuitBreakTask(com.tencent.polaris.circuitbreak.client.task.InstancesCircuitBreakTask)

Aggregations

CircuitBreaker (com.tencent.polaris.api.plugin.circuitbreaker.CircuitBreaker)1 ServiceKey (com.tencent.polaris.api.pojo.ServiceKey)1 InstancesCircuitBreakTask (com.tencent.polaris.circuitbreak.client.task.InstancesCircuitBreakTask)1