-
Notifications
You must be signed in to change notification settings - Fork 507
feat:add Tencent Cloud TSF support. #1391
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
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bcd663d
feat:add Tencent Cloud TSF support.
SkyeBeFreeman 06fffea
fix: move ConditionalOnTsfEnabled to spring-cloud-tencent-commons
fuyuwei01 93e52bf
fix: move ConditionalOnTsfEnabled to spring-cloud-tencent-commons
fuyuwei01 0b4abd4
fix: add Tencent Cloud TSF support.
fuyuwei01 f1e0685
fix: add Tencent Cloud TSF support.
fuyuwei01 b81c222
fix: fix checkstyle
fuyuwei01 df42151
fix: fix context autoconfigure
fuyuwei01 6feb353
fix: fix context autoconfigure
fuyuwei01 898245a
feat:add Tencent Cloud TSF support.
SkyeBeFreeman 9d4073b
fix: fix context autoconfigure
fuyuwei01 9c47535
fix: fix context autoconfigure
fuyuwei01 25bb1b0
fix: fix context autoconfigure
fuyuwei01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...n/java/com/tencent/cloud/polaris/config/tsf/PolarisAdaptorTsfConfigAutoConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...a/com/tencent/cloud/polaris/config/tsf/PolarisAdaptorTsfConfigBootstrapConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...s-config/src/main/java/com/tencent/cloud/polaris/config/tsf/TsfConfigurationModifier.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.