From 275041403dcc50a62131dfce598f646da4dfe8a3 Mon Sep 17 00:00:00 2001 From: Eric Zhao Date: Mon, 11 Nov 2019 19:31:48 +0800 Subject: [PATCH] Update resource classification in SentinelWebFluxFilter and improve reactor EntryConfig Signed-off-by: Eric Zhao --- .../alibaba/csp/sentinel/adapter/reactor/EntryConfig.java | 4 ++++ .../adapter/spring/webflux/SentinelWebFluxFilter.java | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sentinel-adapter/sentinel-reactor-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/reactor/EntryConfig.java b/sentinel-adapter/sentinel-reactor-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/reactor/EntryConfig.java index 1bece3b5..2113d6d2 100644 --- a/sentinel-adapter/sentinel-reactor-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/reactor/EntryConfig.java +++ b/sentinel-adapter/sentinel-reactor-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/reactor/EntryConfig.java @@ -47,6 +47,10 @@ public class EntryConfig { this(resourceName, entryType, 1, new Object[0], contextConfig); } + public EntryConfig(String resourceName, int resourceType, EntryType entryType, ContextConfig contextConfig) { + this(resourceName, resourceType, entryType, 1, new Object[0], contextConfig); + } + public EntryConfig(String resourceName, EntryType entryType, int acquireCount, Object[] args) { this(resourceName, entryType, acquireCount, args, null); } diff --git a/sentinel-adapter/sentinel-spring-webflux-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/webflux/SentinelWebFluxFilter.java b/sentinel-adapter/sentinel-spring-webflux-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/webflux/SentinelWebFluxFilter.java index 0a776364..7d9cbf28 100644 --- a/sentinel-adapter/sentinel-spring-webflux-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/webflux/SentinelWebFluxFilter.java +++ b/sentinel-adapter/sentinel-spring-webflux-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/webflux/SentinelWebFluxFilter.java @@ -18,6 +18,7 @@ package com.alibaba.csp.sentinel.adapter.spring.webflux; import java.util.Optional; import com.alibaba.csp.sentinel.EntryType; +import com.alibaba.csp.sentinel.ResourceTypeConstants; import com.alibaba.csp.sentinel.adapter.reactor.ContextConfig; import com.alibaba.csp.sentinel.adapter.reactor.EntryConfig; import com.alibaba.csp.sentinel.adapter.reactor.SentinelReactorTransformer; @@ -45,7 +46,8 @@ public class SentinelWebFluxFilter implements WebFilter { if (StringUtil.isEmpty(finalPath)) { return chain.filter(exchange); } - return chain.filter(exchange).transform(buildSentinelTransformer(exchange, finalPath)); + return chain.filter(exchange) + .transform(buildSentinelTransformer(exchange, finalPath)); } private SentinelReactorTransformer buildSentinelTransformer(ServerWebExchange exchange, String finalPath) { @@ -53,7 +55,8 @@ public class SentinelWebFluxFilter implements WebFilter { .map(f -> f.apply(exchange)) .orElse(EMPTY_ORIGIN); - return new SentinelReactorTransformer<>(new EntryConfig(finalPath, EntryType.IN, new ContextConfig(finalPath, origin))); + return new SentinelReactorTransformer<>(new EntryConfig(finalPath, ResourceTypeConstants.COMMON_WEB, + EntryType.IN, new ContextConfig(finalPath, origin))); } private static final String EMPTY_ORIGIN = "";