配置
引用eureka依赖的时候内部就已经带人了ribbon,不用单独引用
调用
流程图
入口
相关代码
感兴趣的可以看看这个:www.codingsky.com/doc/2020/6/…
debug
一路追踪
每隔10秒比对一次
定时任务ping服务状态的相关逻辑
com.netflix.loadbalancer.BaseLoadBalancer.Pinger#runPinger
复制代码
从eureka获取服务注册的信息
那ribbon是怎么更新eureka的服务呢?看下去
处理逻辑 每隔30秒更新一次
public synchronized void start(final UpdateAction updateAction) {
if (isActive.compareAndSet(false, true)) {
final Runnable wrapperRunnable = new Runnable() {
@Override
public void run() {
if (!isActive.get()) {
if (scheduledFuture != null) {
scheduledFuture.cancel(true);
}
return;
}
try {
updateAction.doUpdate();
lastUpdated = System.currentTimeMillis();
} catch (Exception e) {
logger.warn("Failed one update cycle", e);
}
}
};
scheduledFuture = getRefreshExecutor().scheduleWithFixedDelay(
wrapperRunnable,
initialDelayMs,
refreshIntervalMs,
TimeUnit.MILLISECONDS
);
} else {
logger.info("Already active, no-op");
}
}
复制代码
后记
到这里就主要流程分析完成了,可能有不足,哈哈哈.下期Feign,敬请期待!
近期评论