com.nepxion.discovery.plugin.strategy.rule.DiscoveryEnabledBaseRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-plugin-strategy Show documentation
Show all versions of discovery-plugin-strategy Show documentation
Nepxion Discovery is an enhancement for Spring Cloud Discovery
package com.nepxion.discovery.plugin.strategy.rule;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import com.nepxion.discovery.plugin.framework.decorator.PredicateBasedRuleDecorator;
import com.netflix.loadbalancer.AbstractServerPredicate;
import com.netflix.loadbalancer.AvailabilityPredicate;
import com.netflix.loadbalancer.CompositePredicate;
public class DiscoveryEnabledBaseRule extends PredicateBasedRuleDecorator {
private CompositePredicate compositePredicate;
private DiscoveryEnabledBasePredicate discoveryEnabledPredicate;
public DiscoveryEnabledBaseRule() {
discoveryEnabledPredicate = new DiscoveryEnabledBasePredicate();
AvailabilityPredicate availabilityPredicate = new AvailabilityPredicate(this, null);
compositePredicate = createCompositePredicate(discoveryEnabledPredicate, availabilityPredicate);
}
private CompositePredicate createCompositePredicate(DiscoveryEnabledBasePredicate discoveryEnabledPredicate, AvailabilityPredicate availabilityPredicate) {
return CompositePredicate.withPredicates(discoveryEnabledPredicate, availabilityPredicate)
// .addFallbackPredicate(availabilityPredicate)
// .addFallbackPredicate(AbstractServerPredicate.alwaysTrue())
.build();
}
@Override
public AbstractServerPredicate getPredicate() {
return compositePredicate;
}
public DiscoveryEnabledBasePredicate getDiscoveryEnabledPredicate() {
return discoveryEnabledPredicate;
}
}