alibaba/Sentinel

Add support for asynchronous Servlet in Sentinel Web Servlet Filter

Open

#306 opened on Dec 15, 2018

View on GitHub
 (7 comments) (0 reactions) (0 assignees)Java (23,109 stars) (8,150 forks)batch import
help wantedkind/enhancement

Description

Issue Description

Type: feature request

Describe what happened (or what feature you want)

Support asynchronous Servlet in Sentinel Web Servlet Filter.

Spring Boot中使用 CompletableFuture<T> or DefferdResult<T> or Callable<T> 作为返回值,引入 Sentinel CommonFilter 后无法响应,且无法正确统计。是否支持两种形式(同步与异步 Servlet)并存,比如使用案例如下:

@RestController
public class AsyncController {

    @GetMapping("/async")
    public CompletableFuture<String> async() {

        return CompletableFuture.supplyAsync(() -> {

                    try {
                        TimeUnit.SECONDS.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    return "async\";
                }
        );

    }

}

Contributor guide