use of com.netflix.loadbalancer.ZoneAffinityServerListFilter in project nutzboot by nutzam.
the class FeignStarter method getLoadBalancer.
public Object getLoadBalancer(String name, FeignInject fc) {
EurekaClient eurekaClient = ioc.get(EurekaClient.class, "eurekaClient");
DefaultClientConfigImpl clientConfig = DefaultClientConfigImpl.getClientConfigWithDefaultValues(name);
ServerList<DiscoveryEnabledServer> list = new DiscoveryEnabledNIWSServerList(name, () -> eurekaClient);
ServerListFilter<DiscoveryEnabledServer> filter = new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(clientConfig);
ServerListUpdater updater = new EurekaNotificationServerListUpdater(() -> eurekaClient);
IRule rule = null;
switch(getLbRuleString(fc.lbRule())) {
case "random":
rule = new RandomRule();
break;
case "availability":
default:
AvailabilityFilteringRule _rule = new AvailabilityFilteringRule();
_rule.initWithNiwsConfig(clientConfig);
rule = _rule;
break;
}
ZoneAwareLoadBalancer<DiscoveryEnabledServer> lb = LoadBalancerBuilder.<DiscoveryEnabledServer>newBuilder().withDynamicServerList(list).withRule(rule).withServerListFilter(filter).withServerListUpdater(updater).withClientConfig(clientConfig).buildDynamicServerListLoadBalancerWithUpdater();
return LBClient.create(lb, clientConfig);
}
Aggregations