Skip to content

feat:add Tencent Cloud TSF support. #1350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dda2aac
feat:add Tencent Cloud TSF support. (#1349
SkyeBeFreeman Jun 6, 2024
1e3bb3e
fix: try to fix maven config
fuyuwei01 Jul 19, 2024
3d3d367
fix: try to update tsf-example config
fuyuwei01 Jul 19, 2024
b6f15a7
fix: update okio to 3.9.0
fuyuwei01 Jul 19, 2024
8478ee8
fix: update okio to 3.9.0
fuyuwei01 Jul 19, 2024
2a1e1ee
fix: fix tsf-example config file
fuyuwei01 Jul 22, 2024
47c7387
fix: fix spring-factories config
fuyuwei01 Jul 22, 2024
f938784
fix: increase delay time after register
fuyuwei01 Jul 22, 2024
0ed0212
fix: add spring.factories configuration for bootstrap and remove spri…
fuyuwei01 Jul 23, 2024
af3f2d7
update: update CHANGELOG.md
fuyuwei01 Jul 23, 2024
75a0874
update: update CHANGELOG.md
fuyuwei01 Jul 23, 2024
afe65cf
feat:add Tencent Cloud TSF support.
fuyuwei01 Jul 23, 2024
3293f8a
Merge remote-tracking branch 'origin/TSF3' into TSF3
fuyuwei01 Jul 23, 2024
86df55e
feat:add Tencent Cloud TSF support.
fuyuwei01 Jul 23, 2024
0c423b1
feat:add Tencent Cloud TSF support.
fuyuwei01 Jul 23, 2024
829162c
fix: fix spring.factories
fuyuwei01 Jul 24, 2024
ad26224
fix: fix spring.factories
fuyuwei01 Jul 24, 2024
779ebaf
fix: fix spring.factories
fuyuwei01 Jul 24, 2024
9f428ab
fix: move @ConditionalOnTsfEnabled to spring-cloud-tencent-commons an…
fuyuwei01 Jul 24, 2024
ad95a48
fix: move @ConditionalOnTsfEnabled to spring-cloud-tencent-commons an…
fuyuwei01 Jul 24, 2024
256b59e
fix: move @ConditionalOnTsfEnabled to spring-cloud-tencent-commons an…
fuyuwei01 Jul 24, 2024
c6ac3c1
update.
SkyeBeFreeman Jul 24, 2024
6e81191
update.
SkyeBeFreeman Jul 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
- [feat:add zero protection.](https://github.com/Tencent/spring-cloud-tencent/pull/1346)
- [fix:fix no registry when lossless is disabled.](https://github.com/Tencent/spring-cloud-tencent/pull/1347)
- [fix:fix the ratelimit bug for 2022](https://github.com/Tencent/spring-cloud-tencent/pull/1348)
- [feat:add Tencent Cloud TSF support.](https://github.com/Tencent/spring-cloud-tencent/pull/1350)
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* @author juanyinyang
*/
public interface PolarisConfigCustomExtensionLayer {
boolean isEnabled();

void initRegisterConfig(PolarisConfigPropertyAutoRefresher polarisConfigPropertyAutoRefresher);

void initConfigFiles(Environment environment, CompositePropertySource compositePropertySource, ConfigFileService configFileService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,25 @@
public final class PolarisServiceLoaderUtil {

private static final Logger LOGGER = LoggerFactory.getLogger(PolarisServiceLoaderUtil.class);
private PolarisServiceLoaderUtil() {
}
// this class provides customized logic for some customers to configure special business group files
private static PolarisConfigCustomExtensionLayer polarisConfigCustomExtensionLayer;

static {
ServiceLoader<PolarisConfigCustomExtensionLayer> polarisConfigCustomExtensionLayerLoader = ServiceLoader.load(PolarisConfigCustomExtensionLayer.class);
Iterator<PolarisConfigCustomExtensionLayer> polarisConfigCustomExtensionLayerIterator = polarisConfigCustomExtensionLayerLoader.iterator();
// Generally, there is only one implementation class. If there are multiple, the last one is loaded
while (polarisConfigCustomExtensionLayerIterator.hasNext()) {
polarisConfigCustomExtensionLayer = polarisConfigCustomExtensionLayerIterator.next();
LOGGER.info("[SCT Config] PolarisConfigFileLocator init polarisConfigCustomExtensionLayer:{}", polarisConfigCustomExtensionLayer);
PolarisConfigCustomExtensionLayer temp = polarisConfigCustomExtensionLayerIterator.next();
if (temp.isEnabled()) {
polarisConfigCustomExtensionLayer = temp;
LOGGER.info("[SCT Config] PolarisConfigFileLocator init polarisConfigCustomExtensionLayer:{}", polarisConfigCustomExtensionLayer);
}
}
}

private PolarisServiceLoaderUtil() {
}

public static PolarisConfigCustomExtensionLayer getPolarisConfigCustomExtensionLayer() {
return polarisConfigCustomExtensionLayer;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.config.tsf;

import com.tencent.cloud.common.tsf.ConditionalOnTsfEnabled;
import com.tencent.cloud.polaris.config.ConditionalOnPolarisConfigEnabled;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import com.tencent.cloud.polaris.config.tsf.controller.PolarisAdaptorTsfConfigController;
import com.tencent.cloud.polaris.context.tsf.config.TsfCoreProperties;
import com.tencent.tsf.consul.config.watch.TsfConsulConfigRefreshEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @author juanyinyang
* @Date Jul 23, 2023 3:52:48 PM
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnTsfEnabled
@ConditionalOnPolarisConfigEnabled
public class PolarisAdaptorTsfConfigAutoConfiguration {

private static final Logger LOGGER = LoggerFactory.getLogger(PolarisAdaptorTsfConfigAutoConfiguration.class);

{
System.setProperty("spring.cloud.polaris.config.refresh-type", "refresh_context");
LOGGER.info(
"[SCTT Config] PolarisAdaptorTsfConfigAutoConfiguration init set spring.cloud.polaris.config.refresh-type to refresh_context");
}

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "spring.cloud.consul.config.watch.enabled", matchIfMissing = true)
public TsfConsulConfigRefreshEventListener polarisAdaptorTsfConsulRefreshEventListener() {
return new TsfConsulConfigRefreshEventListener();
}

/**
* 初始化本类的条件:
* 1、关闭Spring Cloud Consul Config配置开关(如果开启Consul Config配置开关,那么初始化的是tsf自身的类ConfigController)
* 2、开启北极星配置(本类通过注解@ConditionalOnPolarisConfigEnabled开启)
* 3、tsf.config.instance.released-config.lookup.enabled的开关是打开的(默认不配置就是打开的).
*/
@Bean
@ConditionalOnMissingBean
@ConditionalOnExpression("${spring.cloud.consul.config.enabled:true} == false and ${tsf.config.instance.released-config.lookup.enabled:true} == true")
public PolarisAdaptorTsfConfigController polarisAdaptorTsfConfigController() {
return new PolarisAdaptorTsfConfigController();
}

@Bean
@ConditionalOnMissingBean
public TsfConfigurationModifier tsfConfigModifier(TsfCoreProperties tsfCoreProperties, PolarisConfigProperties polarisConfigProperties) {
return new TsfConfigurationModifier(tsfCoreProperties, polarisConfigProperties);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.config.tsf;

import com.tencent.cloud.common.tsf.ConditionalOnTsfEnabled;
import com.tencent.cloud.polaris.config.ConditionalOnPolarisConfigEnabled;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
* @author juanyinyang
* @Date Jul 23, 2023 3:52:48 PM
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty("spring.cloud.polaris.enabled")
@ConditionalOnTsfEnabled
@ConditionalOnPolarisConfigEnabled
@Import(PolarisAdaptorTsfConfigAutoConfiguration.class)
public class PolarisAdaptorTsfConfigBootstrapConfiguration {


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.config.tsf;

import com.tencent.cloud.common.constant.OrderConstant;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import com.tencent.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.cloud.polaris.context.tsf.config.TsfCoreProperties;
import com.tencent.polaris.factory.config.ConfigurationImpl;

/**
* TSF config modifier.
*
* @author Haotian Zhang
*/
public class TsfConfigurationModifier implements PolarisConfigModifier {


private final TsfCoreProperties tsfCoreProperties;

private final PolarisConfigProperties polarisConfigProperties;

public TsfConfigurationModifier(TsfCoreProperties tsfCoreProperties, PolarisConfigProperties polarisConfigProperties) {
this.tsfCoreProperties = tsfCoreProperties;
this.polarisConfigProperties = polarisConfigProperties;
}

@Override
public void modify(ConfigurationImpl configuration) {
if (polarisConfigProperties != null && tsfCoreProperties != null) {
polarisConfigProperties.setEnabled(tsfCoreProperties.isTsePolarisEnable());
}
}

@Override
public int getOrder() {
return OrderConstant.Modifier.CONFIG_ORDER - 1;
}
}
Loading
Loading