docs:update configuration metadata. (#463)

* docs:update configuration metadata.

* docs:update configuration metadata.

* docs:update configuration metadata.

* docs:update configuration metadata.
pull/465/head
Haotian Zhang 2 years ago committed by GitHub
parent f018c439db
commit 3884f29d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,3 +16,4 @@
- [Bugfix: Removed unused class for circuit-breaker module](https://github.com/Tencent/spring-cloud-tencent/pull/455)
- [Optimize: rename opertion EQUAL to EQUALS](https://github.com/Tencent/spring-cloud-tencent/pull/457)
- [Docs: Add featureenv example readme(en) file](https://github.com/Tencent/spring-cloud-tencent/pull/460)
- [docs:update configuration metadata.](https://github.com/Tencent/spring-cloud-tencent/pull/463)

@ -102,7 +102,7 @@ public class PolarisDiscoveryProperties {
* Time unit: millisecond. Default: 5000.
* @see ContextConstant#DEFAULT_REGISTRY_HEARTBEAT_TIME_INTERVAL
*/
private Integer heartBeatInterval = 5000;
private Integer heartbeatInterval = 5000;
/**
* Custom health check url to override default.
@ -211,15 +211,15 @@ public class PolarisDiscoveryProperties {
this.serviceListRefreshInterval = serviceListRefreshInterval;
}
public Integer getHeartBeatInterval() {
if (this.heartbeatEnabled && this.heartBeatInterval <= 0) {
public Integer getHeartbeatInterval() {
if (this.heartbeatEnabled && this.heartbeatInterval <= 0) {
return DEFAULT_REGISTRY_HEARTBEAT_TIME_INTERVAL;
}
return heartBeatInterval;
return heartbeatInterval;
}
public void setHeartBeatInterval(Integer heartBeatInterval) {
this.heartBeatInterval = heartBeatInterval;
public void setHeartbeatInterval(Integer heartbeatInterval) {
this.heartbeatInterval = heartbeatInterval;
}
@Override
@ -235,7 +235,7 @@ public class PolarisDiscoveryProperties {
", enabled=" + enabled +
", registerEnabled=" + registerEnabled +
", heartbeatEnabled=" + heartbeatEnabled +
", heartBeatInterval=" + heartBeatInterval +
", heartbeatInterval=" + heartbeatInterval +
", healthCheckUrl='" + healthCheckUrl + '\'' +
", serviceListRefreshInterval=" + serviceListRefreshInterval +
'}';

@ -18,6 +18,7 @@
package com.tencent.cloud.polaris.discovery;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -29,6 +30,7 @@ import com.tencent.polaris.api.pojo.ServiceInstances;
import com.tencent.polaris.api.rpc.InstancesResponse;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.util.CollectionUtils;
/**
* Polaris service discovery service.
@ -65,6 +67,9 @@ public class PolarisServiceDiscovery {
* @throws PolarisException polarisException
*/
public List<String> getServices() throws PolarisException {
if (CollectionUtils.isEmpty(polarisDiscoveryHandler.GetServices().getServices())) {
return Collections.emptyList();
}
return polarisDiscoveryHandler.GetServices().getServices().stream()
.map(ServiceInfo::getService).collect(Collectors.toList());
}

@ -95,7 +95,7 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
instanceRegisterRequest.setZone(staticMetadataManager.getZone());
instanceRegisterRequest.setCampus(staticMetadataManager.getCampus());
if (null != heartbeatExecutor) {
instanceRegisterRequest.setTtl(polarisDiscoveryProperties.getHeartBeatInterval());
instanceRegisterRequest.setTtl(polarisDiscoveryProperties.getHeartbeatInterval());
}
instanceRegisterRequest.setMetadata(registration.getMetadata());
instanceRegisterRequest.setProtocol(polarisDiscoveryProperties.getProtocol());
@ -186,8 +186,7 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
public void heartbeat(InstanceHeartbeatRequest heartbeatRequest) {
heartbeatExecutor.scheduleWithFixedDelay(() -> {
try {
String healthCheckEndpoint = polarisDiscoveryProperties
.getHealthCheckUrl();
String healthCheckEndpoint = polarisDiscoveryProperties.getHealthCheckUrl();
// First determine whether health-check-url is configured.
// If configured, the service instance health check needs to be executed
// first.
@ -215,6 +214,6 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
catch (Exception e) {
LOG.error("polaris heartbeat runtime error", e);
}
}, polarisDiscoveryProperties.getHeartBeatInterval(), polarisDiscoveryProperties.getHeartBeatInterval(), MILLISECONDS);
}, polarisDiscoveryProperties.getHeartbeatInterval(), polarisDiscoveryProperties.getHeartbeatInterval(), MILLISECONDS);
}
}

@ -24,6 +24,12 @@
"defaultValue": true,
"description": "enable polaris registration or not."
},
{
"name": "spring.cloud.polaris.discovery.heartbeat-interval",
"type": "java.lang.Integer",
"defaultValue": "5000",
"description": "Millis interval of Heart beat. Default: 5000."
},
{
"name": "spring.cloud.polaris.discovery.health-check-url",
"type": "java.lang.String",

@ -42,8 +42,8 @@ public class PolarisDiscoveryPropertiesTest {
assertThat(polarisDiscoveryProperties.isHeartbeatEnabled()).isTrue();
// HeartbeatEnabled
polarisDiscoveryProperties.setHeartBeatInterval(2000);
assertThat(polarisDiscoveryProperties.getHeartBeatInterval()).isEqualTo(2000);
polarisDiscoveryProperties.setHeartbeatInterval(2000);
assertThat(polarisDiscoveryProperties.getHeartbeatInterval()).isEqualTo(2000);
// Namespace
polarisDiscoveryProperties.setNamespace(NAMESPACE_TEST);
@ -100,7 +100,7 @@ public class PolarisDiscoveryPropertiesTest {
+ ", enabled=true"
+ ", registerEnabled=true"
+ ", heartbeatEnabled=true"
+ ", heartBeatInterval=2000"
+ ", heartbeatInterval=2000"
+ ", healthCheckUrl='/health'"
+ ", serviceListRefreshInterval=1000}");
}

@ -1,65 +0,0 @@
/*
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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.tencent.cloud.polaris.router.spi;
import java.util.Collections;
import java.util.Map;
import feign.RequestTemplate;
import org.springframework.core.Ordered;
import org.springframework.http.HttpRequest;
import org.springframework.web.server.ServerWebExchange;
/**
* The spi for resolving labels from request.
*
* @author lepdou 2022-05-11
*/
public interface RouterLabelResolver extends Ordered {
/**
* resolve labels from feign request.
* @param requestTemplate the feign request.
* @return resolved labels
*/
default Map<String, String> resolve(RequestTemplate requestTemplate) {
return Collections.emptyMap();
}
/**
* resolve labels from rest template request.
* @param request the rest template request.
* @param body the rest template request body.
* @return resolved labels
*/
default Map<String, String> resolve(HttpRequest request, byte[] body) {
return Collections.emptyMap();
}
/**
* resolve labels from server web exchange.
* @param exchange the server web exchange.
* @return resolved labels
*/
default Map<String, String> resolve(ServerWebExchange exchange) {
return Collections.emptyMap();
}
}

@ -9,6 +9,11 @@
"name": "spring.cloud.tencent.metadata.transitive",
"type": "java.util.List",
"description": "Custom transitive metadata key list."
},
{
"name": "spring.cloud.tencent.metadata.disposable",
"type": "java.util.List",
"description": "Custom disposable metadata key list."
}
]
}

@ -71,7 +71,7 @@
<properties>
<revision>1.7.0-Hoxton.SR12-SNAPSHOT</revision>
<polaris.version>1.7.1-SNAPSHOT</polaris.version>
<polaris.version>1.7.2-SNAPSHOT</polaris.version>
<logback.version>1.2.11</logback.version>
<mocktio.version>4.5.1</mocktio.version>
<byte-buddy.version>1.12.10</byte-buddy.version>

@ -33,22 +33,22 @@ import org.springframework.http.HttpStatus;
public class RpcEnhancementProperties {
/**
* If circuit-breaker enabled.
* If rpc enhancement enabled.
*/
private boolean enabled = true;
/**
* Specify the Http status code(s) that needs to be fused.
* Specify the Http status code(s) that needs to be reported as FAILED.
*/
private List<HttpStatus> statuses = new ArrayList<>();
/**
* Specify List of HTTP status series.
* Specify List of HTTP status series that needs to be reported as FAILED when status list is empty.
*/
private List<HttpStatus.Series> series = toList(HttpStatus.Series.SERVER_ERROR);
/**
* Ignore Internal Server Error Http Status Code,
* If ignore "Internal Server Error Http Status Code (500)",
* Only takes effect if the attribute {@link RpcEnhancementProperties#series} is not empty.
*/
private boolean ignoreInternalServerError = true;

@ -1,5 +1,29 @@
{
"properties": [
{
"name": "spring.cloud.tencent.rpc-enhancement.enabled",
"type": "java.lang.Boolean",
"defaultValue": true,
"description": "If rpc enhancement enabled."
},
{
"name": "spring.cloud.tencent.rpc-enhancement.ignore-internal-server-error",
"type": "java.lang.Boolean",
"defaultValue": true,
"description": "If ignore \"Internal Server Error Http Status Code (500)\"."
},
{
"name": "sspring.cloud.tencent.rpc-enhancement.series",
"type": "java.util.List<org.springframework.http.HttpStatus.Series>",
"defaultValue": "HttpStatus.Series.SERVER_ERROR",
"description": "Specify List of HTTP status series that needs to be reported as FAILED when status list is empty."
},
{
"name": "sspring.cloud.tencent.rpc-enhancement.statuses",
"type": "java.util.List<org.springframework.http.HttpStatus>",
"defaultValue": "",
"description": "Specify the Http status code(s) that needs to be reported as FAILED."
},
{
"name": "spring.cloud.polaris.stat.enabled",
"type": "java.lang.Boolean",

Loading…
Cancel
Save