alibaba / Sentinel

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
https://sentinelguard.io/
Apache License 2.0
22.38k stars 8.02k forks source link

[Feature] How can i use Sentinel for springCloud gateway circuitbreaker #1317

Closed liangyuanpeng closed 4 years ago

liangyuanpeng commented 4 years ago

Issue Description

Type: feature

Describe what happened (or what feature you want)

I hope I can simply use Sentinel in SpringCloud for circuitbreaker,some like :

        - name: Hystrix
          args:
            name: fallbackcmd
            fallbackUri: forward:/fallback

I searched for a long time for the documentation and didn't find what I wanted.

I am so sad for it

What about spring-cloud-circuitbreaker-sentinel ?

I can not find anything for doc

Describe what you expected to happen

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

Anything else we need to know?

Sentinel for SpringCloud Gateway

cdfive commented 4 years ago

You may refer to the demo of SCA, https://github.com/alibaba/spring-cloud-alibaba/tree/master/spring-cloud-alibaba-examples/sentinel-example/sentinel-core-example

In com.alibaba.cloud.examples.TestController:

@GetMapping("/slow")
public String slow() {
    return circuitBreakerFactory.create("slow").run(() -> {
        try {
            Thread.sleep(500L);
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "slow";
    }, throwable -> "fallback");
}

It demonstrated how to use spring-cloud-circuitbreaker-sentinel.

It's also easy to add some custom fallback, refer to: https://github.com/alibaba/Sentinel/wiki/主流框架的适配 https://github.com/alibaba/Sentinel/wiki/注解支持

InternetPseudonym commented 4 years ago

It's also easy to add some custom fallback, refer to: https://github.com/alibaba/Sentinel/wiki/主流框架的适配 https://github.com/alibaba/Sentinel/wiki/注解支持

almost noone is able to read that

liangyuanpeng commented 4 years ago

Did not solve my problem, for me the way of configuration file is the most ideal