ribbon feign 源码流程分析
2020-06-28 10:36:34 2 举报
ribbon feign 源码流程分析
作者其他创作
大纲/内容
RestTemplateCustomizer
客户端执行
new ZoneAwareLoadBalancer
扫描所有带有FeignClient的类
org.springframework.cloud.netflix.ribbon.apache.RibbonLoadBalancingHttpClient.execute
com.netflix.loadbalancer.DynamicServerListLoadBalancer.DynamicServerListLoadBalancer
获取负载均衡器
生成
com.netflix.loadbalancer.PredicateBasedRule.choose
调用
this.loadBalancer.execute
@Import(FeignClientsRegistrar.class)
执行请求
org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor
com.netflix.loadbalancer.ZoneAwareLoadBalancerZoneAwareLoadBalancer
org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.getServer
导入
new LoadBalancerInterceptor
execute
走负载均衡逻辑
getServer
intercept
构建
去创建负载均衡器
定时任务去获取server
负载均衡器创建完成
org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient
com.netflix.loadbalancer.ZoneAwareLoadBalancer.chooseServer
com.netflix.loadbalancer.AbstractServerPredicate.chooseRoundRobinAfterFiltering
创建负载均衡拦截器
org.springframework.cloud.alibaba.nacos.ribbon.NacosServerList.getUpdatedListOfServers
registerBeanDefinitions
executeWithLoadBalancer
org.springframework.cloud.openfeign.EnableFeignClients
org.springframework.cloud.netflix.ribbon.ribbonLoadBalancer.RibbonClientConfiguration
轮训去选一个server
动态代理
Spring 容器启动
ILoadBalancer loadBalancer = getLoadBalancer(serviceId);
父类
到了nacos的获取服务列表方法
com.netflix.loadbalancer.BaseLoadBalancer.chooseServer
选服务逻辑
org.springframework.http.client.support.InterceptingHttpAccessor
普通流程
org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration
getRequestFactory
AbstractLoadBalancerAwareClient.this.execute
incrementAndGetModulo
选server逻辑
registerFeignClients
restOfInit
registerFeignClient
super
执行
RestTemplate
enableAndInitLearnNewServersFeature
查找是否有拦截器
添加拦截器
updateListOfServers
调用ribbon的请求
loadBalancer.chooseServer
通过算法获取server
0 条评论
下一页