Soul网关源码分析-8期


Soul 网关 HTTP 服务探活机制



准备工作

仅启动 soul-admin 与 soul-bootstrap, soul-admin 中有之前测试 Http 转发时注册的服务路径及服务元数据.

在这种情况下, 看看如果没启动相应服务节点的情况会发生什么.

在这里插入图片描述
在这里插入图片描述



从一个知道会失败的请求开始

尝试调用一个 http路径 http://localhost:9195/http/test/findByUserId?userId=1, 返回值如下:

{
   
  "code": -106,
  "message": "未能找到合适的调用url,请检查你的配置!"
}

继续看看打印的日志信息:

2021-01-20 19:34:42.718  INFO 3929 --- [-work-threads-1] o.d.soul.plugin.base.AbstractSoulPlugin  : divide selector success match , selector name :/http

2021-01-20 19:34:42.719  INFO 3929 --- [-work-threads-1] o.d.soul.plugin.base.AbstractSoulPlugin  : divide rule success match ,rule name :/http/test/**

2021-01-20 19:34:42.723 ERROR 3929 --- [-work-threads-1] o.d.soul.plugin.divide.DividePlugin      : divide upstream configuration error:RuleData(id=1349650853992337408, name=/http/test/**, pluginName=divide, selectorId=1349650852775989248, matchMode=0, sort=1, enabled=true, loged=true, handle={
   "requestVolumeThreshold":"0","errorThresholdPercentage":"0","maxConcurrentRequests":"0","sleepWindowInMilliseconds":"0","loadBalance":"roundRobin","timeout":3000,"retry":"0"}, conditionDataList=[ConditionData(paramType=uri, operator=match, paramName=/, paramValue=/http/test/**)])

从日志可以看出 selector 匹配成功, 因为请求的 /http 与选择器中的相同. rule 匹配也成功, 匹配到 /http/test/**.


最值得注意的是第三行Error级别日志, upstream 相关的错误, 根据日志定位到代码 (仅保留分析代码):

public class DividePlugin extends AbstractSoulPlugin {
   
  
	protected Mono<Void> doExecute(final ServerWebExchange exchange, final SoulPluginChain chain, final SelectorData selector, final RuleData rule) {
   
    // ...
    
    final List<DivideUpstream> upstreamList = UpstreamCacheManager.getInstance().findUpstreamListBySelectorId(selector.getId());
    if (CollectionUtils.isEmpty(upstreamList)) {
   
      LOGGER.error("divide upstream configuration error:{}"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值