spring-cloud-alibaba [Feature][Sentinel]I hope that Sentinel can provide api-group for spring gateway based on yml configuration.

cfh9epnr  于 4个月前  发布在  Spring
关注(0)|答案(3)|浏览(117)

我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。
We recommend using English. If you are non-native English speaker, you can use the translation software.

Original Chinese, using Google Translate.

Which Component
Sentinel, Gateway

Is your feature request related to a problem? Please describe.
NO

Describe the solution you'd like
I hope that Sentinel can provide api-group for spring gateway based on yml configuration.
希望Sentinel能为Spring Gateway提供基于 yml 配置的 api-group .

E.g Java:

Set<ApiDefinition> definitions = new HashSet<>();
        ApiDefinition api1 = new ApiDefinition("some_customized_api")
            .setPredicateItems(new HashSet<ApiPredicateItem>() {{
                add(new ApiPathPredicateItem().setPattern("/ahas"));
                add(new ApiPathPredicateItem().setPattern("/product/**")
                    .setMatchStrategy(SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX));
            }});
        ApiDefinition api2 = new ApiDefinition("another_customized_api")
            .setPredicateItems(new HashSet<ApiPredicateItem>() {{
                add(new ApiPathPredicateItem().setPattern("/**")
                    .setMatchStrategy(SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX));
            }});
        definitions.add(api1);
        definitions.add(api2);
        GatewayApiDefinitionManager.loadApiDefinitions(definitions);

Equivalent yml configuration:

spring:
  cloud:
    sentinel:
      api-group:
        - group-name: some_customized_api
          strategy: PREFIX
          predicateItems:
            - /ahas
            - /product/**
        - group-name: another_customized_api
          strategy: PREFIX
          predicateItems: /**

Describe alternatives you've considered
Currently, Sentinel provides configuration based on Java API and data source. I think that this may decentralize the configuration and resource definition of Sentinel (in the case that both the routing ID and api-group are Sentinel resources).
目前Sentinel提供基于Java API和datasource的方式配置. 我认为这样可能会使Sentinel的配置与资源定义(route id 与 api-group皆为Sentinel资源的情况下)较为分散.

Additional context
Add any other context or screenshots about the feature request here.

3zwjbxry

3zwjbxry1#

welcome to contribute it!

nkoocmlb

nkoocmlb2#

@Lazy-F I don't quite understand this issue. If it's just configurable declaration support for the API, it should be done in sentinel-starter.

mtb9vblg

mtb9vblg3#

maybe need you to elaborate this .

相关问题