package com.changhong.epc.zuul.config;
|
|
import java.io.File;
|
import java.net.MalformedURLException;
|
import java.net.URL;
|
import java.net.URLEncoder;
|
import java.util.Arrays;
|
|
import org.bouncycastle.crypto.tls.URLAndHash;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Scope;
|
import org.springframework.http.MediaType;
|
import org.springframework.web.client.RestTemplate;
|
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
|
import com.iemsoft.framework.cloud.zuul.config.ZuulHystrixConfig;
|
import com.netflix.loadbalancer.BestAvailableRule;
|
import com.netflix.loadbalancer.IPing;
|
import com.netflix.loadbalancer.IRule;
|
import com.netflix.loadbalancer.PingUrl;
|
|
@Configuration
|
public class RibbonConfiguration extends ZuulHystrixConfig{
|
|
/**
|
* ping中心
|
* @return
|
*/
|
@Bean
|
public IPing ribbonPing() {
|
return new PingUrl(false, "/info.json");
|
}
|
|
/**
|
*
|
* @return
|
*/
|
@Bean
|
@Scope("prototype")
|
public IRule ribbonRule() {
|
// return new BestAvailableRule(); //閫夋嫨涓�涓渶灏忕殑骞跺彂璇锋眰鐨剆erver
|
// return new WeightedResponseTimeRule(); //鏍规嵁鐩稿簲鏃堕棿鍒嗛厤涓�涓獁eight锛岀浉搴旀椂闂磋秺闀匡紝weight瓒婂皬锛岃閫変腑鐨勫彲鑳芥�ц秺浣庛��
|
// return new RetryRule(); //瀵归�夊畾鐨勮礋杞藉潎琛$瓥鐣ユ満涓婇噸璇曟満鍒躲��
|
// return new RoundRobinRule(); //roundRobin鏂瑰紡杞閫夋嫨server
|
// return new RandomRule(); //闅忔満閫夋嫨涓�涓猻erver
|
// return new ZoneAvoidanceRule(); //澶嶅悎鍒ゆ柇server鎵�鍦ㄥ尯鍩熺殑鎬ц兘鍜宻erver鐨勫彲鐢ㄦ�ч�夋嫨server
|
return new BestAvailableRule();
|
}
|
|
}
|