spring-cloud-alibaba Support for RestTemplate for more fine-grained degradation processing

3df52oht  于 2022-11-02  发布在  Spring
关注(0)|答案(2)|浏览(119)

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

Which Component

Sentinel

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

Based on the following inspiration, an enhancement could be made to implement the RestTemplate's fine-grained treatment of degradation, as with feign's fallback.
There are some differences in the way they are used.
Is it necessary to do this enhancement? I don't know if it's good or bad.
Feel free to comment.

#483

Please refer to the following description for details

Describe the solution you'd like

用户若使用降级/限流,则必须继承自RestTemplateFallbackFactory,这个父类中只有两个兜底的方法(throttle和degrade)
若要对uri进行细粒度的控制,则在子类中新增降级时回调的方法,该方法可以用UriMapping注解来实指定uri与回调方法的Map,也可以不使用uriMapping注解,但回调方法名必须与uri驼峰名一致(回调方法名和uri的转换可以在子类被重写)
If a user using the drop/current limit, it must be inherited from RestTemplateFallbackFactory, only two out of the parent class method (throttle and degrade).
For fine-grained control of uris, add a demotion callback method in the subclass, which USES the UriMapping annotation to actually specify the mapping of uris to callback methods.
You can also do without the uriMapping annotation, but the callback method name must be the same as the uri camel name (the callback method name and uri transformation can be overridden in subclasses)
该思路已经有初步实现,可供参考:
This idea has been preliminarily realized for reference:
RestTemplateFallbackBeanPostProcessor
RestTemplateFallbackFactory
URIMapping
.......Other classes are not enumerated

the example :

TestRestTemplateFallbackFactory

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

i2byvkas

i2byvkas1#

Maybe we could do it like this #483 (comment), it's simply and easy to understand.

This issue need more people to discuss about it.

r8xiu3jd

r8xiu3jd2#

Personally, I prefer to simplify the implementation of dealing with degradation when users use the RestTemplate.
Because more fine-grained control is available, users can determine its scope.
Hopefully more people will discuss about it.

相关问题