com.github.edgar615.util.loadbalance.ProviderStrategy Maven / Gradle / Ivy
package com.github.edgar615.util.loadbalance;
import java.util.List;
/**
* 从一组节点中选择一个节点的策略.
*
* 主要是用来实现服务发现的负载均衡
*
* @author Edgar
*/
public interface ProviderStrategy {
/**
* 从给定一组对象中,返回一个对象.
*
* @param instances the instance list
* @return the instance to use
*/
ServiceInstance get(List instances);
static ProviderStrategy random() {
return new RandomStrategy();
}
static ProviderStrategy weightRoundRobin() {
return new WeightRoundbinStrategy();
}
static ProviderStrategy roundRobin() {
return new RoundRobinStrategy();
}
static ProviderStrategy sticky(ProviderStrategy masterStrategy) {
return new StickyStrategy(masterStrategy);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy