Skip to content

Commit

Permalink
*fix an issue where inputstream is sometimes lost.
Browse files Browse the repository at this point in the history
Signed-off-by: provenceee <[email protected]>
  • Loading branch information
provenceee committed Nov 14, 2024
1 parent 40caf06 commit e3d8442
Show file tree
Hide file tree
Showing 21 changed files with 648 additions and 513 deletions.
6 changes: 0 additions & 6 deletions sermant-plugins/sermant-router/spring-router-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

package com.huaweicloud.sermant.router.spring.handler;

import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager;
import com.huaweicloud.sermant.router.spring.service.SpringConfigService;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* AbstractHandlerMapping处理器
Expand All @@ -29,27 +27,47 @@
* @since 2023-02-21
*/
public abstract class AbstractMappingHandler extends AbstractHandler {
/**
* 配置服务
*/
protected final SpringConfigService configService;

/**
* 构造方法
*/
public AbstractMappingHandler() {
configService = PluginServiceManager.getPluginService(SpringConfigService.class);
}

/**
* 获取透传的标记
*
* @param path 请求路径
* @param methodName http方法
* @param headers http请求头
* @param parameters url参数
* @param keys 透传标记key
* @return 透传的标记
*/
public abstract Map<String, List<String>> getRequestTag(String path, String methodName,
Map<String, List<String>> headers, Map<String, List<String>> parameters);
Map<String, List<String>> headers, Map<String, List<String>> parameters, Keys keys);

/**
* 透传标记key实体
*
* @author provenceee
* @since 2023-02-21
*/
public static class Keys {
private final Set<String> matchKeys;

private final Set<String> injectTags;

/**
* 构造方法
*
* @param matchKeys 标签路由透传标记
* @param injectTags 泳道透传标记
*/
public Keys(Set<String> matchKeys, Set<String> injectTags) {
this.matchKeys = matchKeys;
this.injectTags = injectTags;
}

public Set<String> getMatchKeys() {
return matchKeys;
}

public Set<String> getInjectTags() {
return injectTags;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.huaweicloud.sermant.router.spring.handler;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* web拦截器处理器
*
* @author provenceee
* @since 2023-02-21
*/
public abstract class AbstractRequestTagHandler extends AbstractHandler {
/**
* 获取透传的标记
*
* @param path 请求路径
* @param methodName http方法
* @param headers http请求头
* @param parameters url参数
* @param keys 透传标记key
* @return 透传的标记
*/
public abstract Map<String, List<String>> getRequestTag(String path, String methodName,
Map<String, List<String>> headers, Map<String, String[]> parameters, Keys keys);

/**
* 透传标记key实体
*
* @author provenceee
* @since 2023-02-21
*/
public static class Keys {
private final Set<String> matchKeys;

private final Set<String> injectTags;

/**
* 构造方法
*
* @param matchKeys 标签路由透传标记
* @param injectTags 泳道透传标记
*/
public Keys(Set<String> matchKeys, Set<String> injectTags) {
this.matchKeys = matchKeys;
this.injectTags = injectTags;
}

public Set<String> getMatchKeys() {
return matchKeys;
}

public Set<String> getInjectTags() {
return injectTags;
}
}
}
///*
// * Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.huaweicloud.sermant.router.spring.handler;
//
//import java.util.List;
//import java.util.Map;
//import java.util.Set;
//
///**
// * web拦截器处理器
// *
// * @author provenceee
// * @since 2023-02-21
// */
//public abstract class AbstractRequestTagHandler extends AbstractHandler {
// /**
// * 获取透传的标记
// *
// * @param path 请求路径
// * @param methodName http方法
// * @param headers http请求头
// * @param parameters url参数
// * @param keys 透传标记key
// * @return 透传的标记
// */
// public abstract Map<String, List<String>> getRequestTag(String path, String methodName,
// Map<String, List<String>> headers, Map<String, String[]> parameters, Keys keys);
//
// /**
// * 透传标记key实体
// *
// * @author provenceee
// * @since 2023-02-21
// */
// public static class Keys {
// private final Set<String> matchKeys;
//
// private final Set<String> injectTags;
//
// /**
// * 构造方法
// *
// * @param matchKeys 标签路由透传标记
// * @param injectTags 泳道透传标记
// */
// public Keys(Set<String> matchKeys, Set<String> injectTags) {
// this.matchKeys = matchKeys;
// this.injectTags = injectTags;
// }
//
// public Set<String> getMatchKeys() {
// return matchKeys;
// }
//
// public Set<String> getInjectTags() {
// return injectTags;
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public LaneMappingHandler() {
*/
@Override
public Map<String, List<String>> getRequestTag(String path, String methodName, Map<String, List<String>> headers,
Map<String, List<String>> parameters) {
Set<String> injectTags = configService.getInjectTags();
Map<String, List<String>> parameters, Keys keys) {
Set<String> injectTags = keys.getInjectTags();
if (CollectionUtils.isEmpty(injectTags)) {
// 染色标记为空,代表没有染色规则,直接return
LOGGER.fine("Lane tags are empty.");
Expand Down
Loading

0 comments on commit e3d8442

Please sign in to comment.