Skip to content

Commit

Permalink
feat: dubbo supports redefinition of exception return codes
Browse files Browse the repository at this point in the history
  • Loading branch information
markGbug authored and trickMin committed Nov 28, 2022
1 parent 263d4d0 commit 6291b9f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class GlobalConfig {
@Value("${telnet.connect.timeout:3000}")
private Integer telnetConnectTimeout;

@Value("${customDefaultRespCode:500}")
private int customDefaultRespCode;

public String getResourceNamespace() {
return resourceNamespace;
}
Expand All @@ -40,4 +43,8 @@ public String getApiPlaneVersion() {
public Integer getTelnetConnectTimeout() {
return telnetConnectTimeout;
}

public int getCustomDefaultRespCode() {
return customDefaultRespCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public List<K8sResourcePack> translate(API api, boolean simple) {
.map(FragmentHolder::getVirtualServiceFragment)
.collect(Collectors.toList());
}
if (NumberUtils.INTEGER_ZERO.equals(api.getCustomDefaultRespCode())){
api.setCustomDefaultRespCode(globalConfig.getCustomDefaultRespCode());
}
List<String> rawVirtualServices = renderTwiceModelProcessor
.process(apiVirtualService, api,
new PortalVirtualServiceAPIDataHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public TemplateParams handleApi(API api) {
.put(VIRTUAL_SERVICE_REQUEST_HEADERS, api.getRequestOperation())
.put(VIRTUAL_SERVICE_VIRTUAL_CLUSTER_NAME, api.getVirtualClusterName())
.put(VIRTUAL_SERVICE_VIRTUAL_CLUSTER_HEADERS, getVirtualClusterHeaders(api))
.put(VIRTUAL_SERVICE_RESP_EXCEPTION_CODE, api.getCustomDefaultRespCode())
;

return handleApiMetaMap(api,tp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public interface TemplateConst {
String VIRTUAL_SERVICE_STATS = "t_virtual_service_stats";
String VIRTUAL_SERVICE_DUBBO = "t_virtual_service_dubbo";

String VIRTUAL_SERVICE_RESP_EXCEPTION_CODE ="t_virtual_service_resp_exception_code";


/**
* ServiceInfo
**/
Expand Down
21 changes: 21 additions & 0 deletions hango-api-plane-server/src/main/java/org/hango/cloud/meta/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ public class API extends CommonModel {
*/
private Map<String, String> metaMap;

private Long version;


private int customDefaultRespCode;

public Service getMirrorTraffic() {
return mirrorTraffic;
}
Expand Down Expand Up @@ -529,4 +534,20 @@ public Map<String, String> getMetaMap() {
public void setMetaMap(Map<String, String> metaMap) {
this.metaMap = metaMap;
}

public Long getVersion() {
return version;
}

public void setVersion(Long version) {
this.version = version;
}

public int getCustomDefaultRespCode() {
return customDefaultRespCode;
}

public void setCustomDefaultRespCode(int customDefaultRespCode) {
this.customDefaultRespCode = customDefaultRespCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ metadata:

<#if t_virtual_service_dubbo_meta_service?has_content >
proxy.upstreams.http.dubbo:
<#if t_virtual_service_resp_exception_code??>
resp_exception_code: ${t_virtual_service_resp_exception_code}
</#if>
context:
service: ${t_virtual_service_dubbo_meta_service}
version: ${t_virtual_service_dubbo_meta_version}
Expand Down

0 comments on commit 6291b9f

Please sign in to comment.