use of com.hummer.doorgod.service.domain.configuration.LoadBalancerConfig in project hummer-framework by hummer-team.
the class GlobalLoadBalancerFilter method choose.
private Mono<Response<ServiceInstance>> choose(ServerWebExchange exchange) {
URI uri = Objects.requireNonNull(exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR));
String routeId = ((Route) Objects.requireNonNull(exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR))).getId();
LoadBalancerConfig loadBalancerConfig = routeRepository.getLoadBalancer(routeId, () -> LoadBalancerConfig.DEFAULT);
BaseReactorServiceInstanceLoadbalancer loadBalancer = loadbalancerMap.get(loadBalancerConfig.getLoadBalancerName());
if (loadBalancer == null) {
loadBalancer = loadbalancerMap.get("roundLb");
log.debug("this service {} loadBalancerName {} invalid,use default loadBalancer `roundLb`", uri.getHost(), loadBalancerConfig.getLoadBalancerName());
}
return loadBalancer.tryChoose(createRequest(exchange, uri.getHost()), uri.getHost(), loadBalancerConfig);
}
Aggregations