feat:support consul config.

pull/1319/head
Haotian Zhang 1 year ago
parent 03b2244bab
commit 7b2b56eacb

@ -28,6 +28,16 @@ import com.tencent.cloud.polaris.tsf.TsfDiscoveryProperties;
import com.tencent.cloud.polaris.tsf.consts.WarmupCons; import com.tencent.cloud.polaris.tsf.consts.WarmupCons;
import com.tencent.cloud.polaris.tsf.util.RegistrationUtil; import com.tencent.cloud.polaris.tsf.util.RegistrationUtil;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_APPLICATION_ID;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_GROUP_ID;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_INSTNACE_ID;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_NAMESPACE_ID;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_PROG_VERSION;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_REGION;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_SDK_VERSION;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_TAGS;
import static com.tencent.cloud.common.tsf.TsfConstant.TSF_ZONE;
/** /**
* *
* *
@ -48,17 +58,17 @@ public class TsfMetadataPolarisRegistrationCustomizer implements PolarisRegistra
public void customize(PolarisRegistration registration) { public void customize(PolarisRegistration registration) {
Map<String, String> metadata = registration.getMetadata(); Map<String, String> metadata = registration.getMetadata();
metadata.put("TSF_APPLICATION_ID", tsfCoreProperties.getTsfApplicationId()); metadata.put(TSF_APPLICATION_ID, tsfCoreProperties.getTsfApplicationId());
metadata.put("TSF_PROG_VERSION", tsfDiscoveryProperties.getTsfProgVersion()); metadata.put(TSF_PROG_VERSION, tsfDiscoveryProperties.getTsfProgVersion());
metadata.put("TSF_GROUP_ID", tsfCoreProperties.getTsfGroupId()); metadata.put(TSF_GROUP_ID, tsfCoreProperties.getTsfGroupId());
metadata.put("TSF_NAMESPACE_ID", tsfCoreProperties.getTsfNamespaceId()); metadata.put(TSF_NAMESPACE_ID, tsfCoreProperties.getTsfNamespaceId());
metadata.put("TSF_INSTNACE_ID", tsfDiscoveryProperties.getInstanceId()); metadata.put(TSF_INSTNACE_ID, tsfDiscoveryProperties.getInstanceId());
metadata.put("TSF_REGION", tsfDiscoveryProperties.getTsfRegion()); metadata.put(TSF_REGION, tsfDiscoveryProperties.getTsfRegion());
metadata.put("TSF_ZONE", tsfDiscoveryProperties.getTsfZone()); metadata.put(TSF_ZONE, tsfDiscoveryProperties.getTsfZone());
// 处理预热相关的参数 // 处理预热相关的参数
metadata.put(WarmupCons.TSF_START_TIME, String.valueOf(System.currentTimeMillis())); metadata.put(WarmupCons.TSF_START_TIME, String.valueOf(System.currentTimeMillis()));
metadata.put("TSF_SDK_VERSION", SdkVersion.get()); metadata.put(TSF_SDK_VERSION, SdkVersion.get());
metadata.put("TSF_TAGS", JacksonUtils.serialize2Json(RegistrationUtil.createTags(tsfDiscoveryProperties))); metadata.put(TSF_TAGS, JacksonUtils.serialize2Json(RegistrationUtil.createTags(tsfDiscoveryProperties)));
RegistrationUtil.appendMetaIpAddress(metadata); RegistrationUtil.appendMetaIpAddress(metadata);
} }
} }

@ -0,0 +1,73 @@
/*
* 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.common.tsf;
/**
* Constant for TSF.
*
* @author Haotian Zhang
*/
public final class TsfConstant {
/**
* tsf application id.
*/
public static String TSF_APPLICATION_ID = "TSF_APPLICATION_ID";
/**
* tsf program version.
*/
public static String TSF_PROG_VERSION = "TSF_PROG_VERSION";
/**
* tsf group id.
*/
public static String TSF_GROUP_ID = "TSF_GROUP_ID";
/**
* tsf namespace id.
*/
public static String TSF_NAMESPACE_ID = "TSF_NAMESPACE_ID";
/**
* tsf instance id.
*/
public static String TSF_INSTNACE_ID = "TSF_INSTNACE_ID";
/**
* tsf region.
*/
public static String TSF_REGION = "TSF_REGION";
/**
* tsf zone.
*/
public static String TSF_ZONE = "TSF_ZONE";
/**
* tsf SDK version.
*/
public static String TSF_SDK_VERSION = "TSF_SDK_VERSION";
/**
* tsf tags.
*/
public static String TSF_TAGS = "TSF_TAGS";
private TsfConstant() {
}
}
Loading…
Cancel
Save