查看Spring Actuator MetricsWebFilter并看到了这段代码:@Overridepublic Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) { return chain.filter(exchange).compose((call) -> filter(exchange, call));}private Publisher<Void> filter(ServerWebExchange exchange, Mono<Void> call) { long start = System.nanoTime(); ServerHttpResponse response = exchange.getResponse(); return call.doOnSuccess((done) -> success(exchange, start)) ... more code ...}没有compose()映射会有什么区别吗?@Overridepublic Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) { return chain.filter(exchange).doOnSuccess( ... ) ... more code...}我的线索是,compose()与transform(). doOnSuccess()但是每个订阅者也执行一次。是否只是为了方便,使用filter(...)函数而不是内联代码?
添加回答
举报
0/150
提交
取消