alibaba/Sentinel

Add support for asynchronous Servlet in Sentinel Web Servlet Filter

Open

#306 创建于 2018年12月15日

在 GitHub 查看
 (7 评论) (0 反应) (0 负责人)Java (23,109 star) (8,150 fork)batch import
help wantedkind/enhancement

描述

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\";
                }
        );

    }

}

贡献者指南