use of io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRoundRobinLoadBalancer in project gravitee-gateway by gravitee-io.
the class InvokerFactory method doCreateInstance.
@Override
protected Invoker doCreateInstance() throws Exception {
LoadBalancer lb = api.getProxy().getLoadBalancer();
DefaultInvoker invoker;
if (lb != null) {
switch(lb.getType()) {
case RANDOM:
invoker = new RandomLoadBalancer(endpointManager.endpoints());
break;
case WEIGHTED_RANDOM:
invoker = new WeightedRandomLoadBalancer(endpointManager.endpoints());
break;
case WEIGHTED_ROUND_ROBIN:
invoker = new WeightedRoundRobinLoadBalancer(endpointManager.endpoints());
break;
default:
invoker = new RoundRobinLoadBalancer(endpointManager.endpoints());
break;
}
} else {
invoker = new RoundRobinLoadBalancer(endpointManager.endpoints());
}
if (api.getProxy().failoverEnabled()) {
applicationContext.getAutowireCapableBeanFactory().autowireBean(invoker);
invoker = new FailoverInvoker(invoker);
}
return invoker;
}
Aggregations