Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring-cloud-tencent规则路由未匹配上不报错问题 #1217

Open
relaxXiaoLuo opened this issue Jan 3, 2024 · 4 comments
Open

spring-cloud-tencent规则路由未匹配上不报错问题 #1217

relaxXiaoLuo opened this issue Jan 3, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@relaxXiaoLuo
Copy link

服务A访问服务B 配置了规则路由
当时当A访问B时,规则未匹配上,不会报错,会直接去访问从注册中心拿到的实例,我需要如何配置才能实现当配置了路由规则时,调用服务是不符合规则报错或提示未找到服务呢?
我查到的代码如下:
LOG.warn("route rule not match, rule status: {}, not matched source {}", ruleStatus, routeInfo.getSourceService());
RuleBasedRouterFailoverType failoverType = routeInfo.getRuleBasedRouterFailoverType();
if (failoverType == null) {
failoverType = this.routerConfig.getFailoverType();
}

        return failoverType == RuleBasedRouterFailoverType.none ? new RouteResult(Collections.emptyList(), State.Next) : new RouteResult(instances.getInstances(), State.Next);

这里failoverType 默认是all
spring-cloud-tencent 中如何设置RuleBasedRouterFailoverType为none 或者如何通过其他方式解决这个问题呢?

@relaxXiaoLuo relaxXiaoLuo added the question Further information is requested label Jan 3, 2024
@SkyeBeFreeman
Copy link
Collaborator

目前只能在resource/polaris.yml下添加如下配置,来指定降级策略为none。下个版本可以新增sct配置降级策略。

consumer:
  serviceRouter:
    plugin:
      ruleBasedRouter
        failoverType: none

@SkyeBeFreeman SkyeBeFreeman added enhancement New feature or request and removed question Further information is requested labels Jan 4, 2024
@SkyeBeFreeman SkyeBeFreeman added this to the 1.14.0 milestone Jan 4, 2024
@relaxXiaoLuo
Copy link
Author

relaxXiaoLuo commented Jan 4, 2024

目前只能在resource/polaris.yml下添加如下配置,来指定降级策略为none。下个版本可以新增sct配置降级策略。

consumer:
  serviceRouter:
    plugin:
      ruleBasedRouter
        failoverType: none

通过配置实现了将failoverType 设置为none,但是当规则未匹配时还是能调用到下级服务;
我现在遇到的情况就是规则没有匹配上,还是能正确的调用到被调服务;
如何设置当配置了A访问B的路由规则时,规则未匹配上时,返回报错呢 ?

@SkyeBeFreeman
Copy link
Collaborator

看了一下代码,仅仅修改降级策略不够,sct的代码也有需要修改的地方。可以在下个版本提供这个功能。如有兴趣,您可以参与开源共建。目前设置了降级策略,但还是返回实例列表的地方的处理在这里:
image

@relaxXiaoLuo
Copy link
Author

看了一下代码,仅仅修改降级策略不够,sct的代码也有需要修改的地方。可以在下个版本提供这个功能。如有兴趣,您可以参与开源共建。目前设置了降级策略,但还是返回实例列表的地方的处理在这里: image

好的,自己闲余时间才接触SCT,我先了解了解 谢谢。

@SkyeBeFreeman SkyeBeFreeman removed this from the 1.14.0 milestone Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants