spring-cloud-practice's People
Forkers
lowzj chakra-coder xjz1842 yushiwh hadoop835 softwareking chenlushun fullyfang henryleecn miaowing duyunqiang onlyisssilence itjinkui qiangzhu sunquanchao tinyhome googlefan qilifan goldenheart 21guns startsnow charlesion wenxiaoqian coder1650 jifeer d491675881 rucky2013 russellchang54 keven0706 shanhaidaye funfei1987 rockjava extremeyu stoneyliu qzztf agangdundan bill1012 jiaozg linbaoji godmars shuchang01 pzlsun yuhuanxi comlkz yorkexing alwaysc bujinli suxg003 randaliang langgege grasshourse wang-ray gengkangkang donjote hlzhang123 gotoworld jasluen 94192448 qiushijun kaysonyang lrg30067 lazycathome zywj clude jackyfan liujiuwu heshouyou springdew84 trendsoa huacw bobbyguo itcrazer zhanglin00129 andrewjonhnlee zhangkungit johnnywong233 qq85609655 pettyferlove dwj1979 spring-cloud-book zerohyuan jacoblunt shenenlutc nikyotensai starengry quicksandznzn hqz010 he-jialin a330222803 xmzfzpd ferry1376122 conchz neogitcrt1 ylsn19821104 czy880816 musilin roky hongzhenglin ichiranakita robtspring-cloud-practice's Issues
HystrixRequestVariableDefault 获取不到存入的数据
把您的CoreHeaderInterceptor 搬过去就改了 存入类型 在 LabelAndWeightMetadataRule里面获取为空 ,是我哪没有 弄好么?
`
public class DevInterceptor extends HandlerInterceptorAdapter {
public static final String DEV_EUREKA_HEADER="DEV_EUREKA_HEADER";
public static final HystrixRequestVariableDefault THREAD_LOCAL = new HystrixRequestVariableDefault<>();
public static void initHystrixRequestContext(DevConfig labels) {
if (!HystrixRequestContext.isCurrentThreadInitialized()) {
HystrixRequestContext.initializeContext();
}
labels=labels!=null?labels:new DevConfig();
DevInterceptor.THREAD_LOCAL.set(labels);
}
public static void shutdownHystrixRequestContext() {
if (HystrixRequestContext.isCurrentThreadInitialized()) {
HystrixRequestContext.getContextForCurrentThread().shutdown();
}
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
DevConfig devConfig=null;
try {
String header = request.getHeader(DEV_EUREKA_HEADER);
if(StringUtils.isNotEmpty(header)){
try {
devConfig = JSON.parseObject(Base64.getDecoder().decode(header),DevConfig.class);
}catch (Exception e){
e.printStackTrace();
}
}
}catch (Exception e){
e.printStackTrace();
}
DevInterceptor.initHystrixRequestContext(devConfig);
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
DevInterceptor.shutdownHystrixRequestContext();
}
}
`
`
public class DevMetadataRule extends ZoneAvoidanceRule {
private Random random = new Random();
@Override
public Server choose(Object key) {
DevConfig config = DevInterceptor.THREAD_LOCAL.get();
//config 为null
}
}
`
现在已经到spring cloud gateway了,有对应的升级吗
consumer调用provider没有按照权重请求
如果我直接设置consumer的权重,并通过zuul转发的话,是会根据权重值请求的.
但是当我设置了consumer和provider的权重后,并通过zuul请求consumer,然后consumer通过restTemplate调用provider,这个时候,provider的权重值是不生效的!
如何解决这种连续调用的权重处理? 请指教.跪求
gateway需要更新的话,如何金丝雀发布呢
如果调用的话换成FeignClient的,header的请求能带过去吗
现在是放在header里的,但是如果是http+rpc,怎么办?
LabelAndWeightMetadataRule 灰度标签问题
场景:根据灰度标签过滤是否将用户转移到灰度环境。
环境的筛选应该放到 IFilter 进行扩展,
IRule 是负载均衡规则,比如根据lable选择出该请求应该转发到灰度环境,IRule 负责按照规则选择灰度环境的服务实例。
使用标签后 就不是负载均衡了
for (Server server : serverList)
循环遍历后 就直接返回匹配的 server。 如果有多个匹配 就不可以了
rule有明显bug,建议扩展predicate
底下这段代码永远只返回第一个符合条件的实例。父类的roundrobin被你忽略了。
// 优先匹配label String labelOr = metadata.get(META_DATA_KEY_LABEL_OR); if(!StringUtils.isEmpty(labelOr)){ List<String> metadataLabel = Arrays.asList(labelOr.split(CoreHeaderInterceptor.HEADER_LABEL_SPLIT)); for (String label : metadataLabel) { if(CoreHeaderInterceptor.label.get().contains(label)){ return server; } } }
核心判断建议通过扩展AbstractServerPredicate来实现。
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.