Skip to content

Commit 5071048

Browse files
authored
refactor: Refactor Polaris config loading and unit test (#94)
1 parent dfb2d7e commit 5071048

File tree

26 files changed

+1845
-1934
lines changed

26 files changed

+1845
-1934
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making dubbo-polaris-java available.
3+
*
4+
* Copyright (C) 2021 Tencent. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package com.tencent.polaris.dubbo.circuitbreaker;
19+
20+
import com.tencent.polaris.common.config.BootConfigHandler;
21+
import com.tencent.polaris.common.config.PolarisConfig;
22+
import com.tencent.polaris.factory.config.ConfigurationImpl;
23+
import java.util.Map;
24+
25+
public class CircuitBreakerBootConfigHandler implements BootConfigHandler {
26+
27+
@Override
28+
public void handle(PolarisConfig polarisConfig, Map<String, String> parameters, ConfigurationImpl configuration) {
29+
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
circuitBreakerBootConfigHandler = com.tencent.polaris.dubbo.circuitbreaker.CircuitBreakerBootConfigHandler
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making dubbo-polaris-java available.
3+
*
4+
* Copyright (C) 2021 Tencent. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package com.tencent.polaris.dubbo.configuration;
19+
20+
import com.tencent.polaris.common.config.BootConfigHandler;
21+
import com.tencent.polaris.common.config.PolarisConfig;
22+
import com.tencent.polaris.common.utils.Consts;
23+
import com.tencent.polaris.factory.config.ConfigurationImpl;
24+
import java.util.Collections;
25+
import java.util.Map;
26+
27+
public class ConfigCenterBootConfigHandler implements BootConfigHandler {
28+
29+
@Override
30+
public void handle(PolarisConfig polarisConfig, Map<String, String> parameters, ConfigurationImpl configuration) {
31+
// 设置配置中心连接地址
32+
configuration.getConfigFile().getServerConnector()
33+
.setAddresses(polarisConfig.getConfigAddresses());
34+
// 禁用配置推空保护
35+
configuration.getConfigFile().getServerConnector().setEmptyProtectionEnable(false);
36+
configuration.getConfigFile().getConfigFilterConfig()
37+
.setEnable(Boolean.parseBoolean(parameters.getOrDefault(Consts.KEY_CONFIG_ENCRYPT_ENABLED, "true")));
38+
configuration.getConfigFile().getConfigFilterConfig().getChain().add("crypto");
39+
configuration.getConfigFile().getConfigFilterConfig().getPlugin()
40+
.put("crypto", Collections.singletonMap("type", "AES"));
41+
}
42+
}

dubbo-plugins/dubbo-configcenter-polaris/src/main/java/com/tencent/polaris/dubbo/configuration/PolarisDynamicConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import com.tencent.polaris.api.plugin.event.EventConstants;
2525
import com.tencent.polaris.client.api.SDKContext;
2626
import com.tencent.polaris.client.flow.BaseFlow;
27-
import com.tencent.polaris.common.registry.PolarisConfig;
27+
import com.tencent.polaris.common.config.PolarisConfig;
2828
import com.tencent.polaris.common.registry.PolarisOperator;
2929
import com.tencent.polaris.common.registry.PolarisOperators;
3030
import com.tencent.polaris.configuration.api.core.ChangeType;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
configCenterBootConfigHandler = com.tencent.polaris.dubbo.configuration.ConfigCenterBootConfigHandler

dubbo-plugins/dubbo-configcenter-polaris/src/test/java/com/tencent/polaris/dubbo/configuration/PolarisConfigCenterIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import static org.mockito.Mockito.verify;
3232
import static org.mockito.Mockito.when;
3333

34-
import com.tencent.polaris.common.registry.PolarisConfig;
34+
import com.tencent.polaris.common.config.PolarisConfig;
3535
import com.tencent.polaris.common.registry.PolarisOperator;
3636
import com.tencent.polaris.common.registry.PolarisOperators;
3737
import com.tencent.polaris.configuration.api.core.ConfigFilePublishService;

dubbo-plugins/dubbo-configcenter-polaris/src/test/java/com/tencent/polaris/dubbo/configuration/PolarisDynamicConfigurationFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import static org.mockito.Mockito.mock;
2828
import static org.mockito.Mockito.when;
2929

30-
import com.tencent.polaris.common.registry.PolarisConfig;
30+
import com.tencent.polaris.common.config.PolarisConfig;
3131
import com.tencent.polaris.common.registry.PolarisOperator;
3232
import com.tencent.polaris.common.registry.PolarisOperators;
3333
import com.tencent.polaris.configuration.api.core.ConfigFilePublishService;

dubbo-plugins/dubbo-configcenter-polaris/src/test/java/com/tencent/polaris/dubbo/configuration/PolarisDynamicConfigurationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import com.tencent.polaris.api.plugin.configuration.ConfigFileResponse;
4040
import com.tencent.polaris.client.api.SDKContext;
4141
import com.tencent.polaris.client.flow.BaseFlow;
42-
import com.tencent.polaris.common.registry.PolarisConfig;
42+
import com.tencent.polaris.common.config.PolarisConfig;
4343
import com.tencent.polaris.common.registry.PolarisOperator;
4444
import com.tencent.polaris.common.registry.PolarisOperators;
4545
import com.tencent.polaris.configuration.api.core.ChangeType;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making dubbo-polaris-java available.
3+
*
4+
* Copyright (C) 2021 Tencent. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package com.tencent.polaris.dubbo.ratelimit;
19+
20+
public class RateLimitBootConfigHandler {
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rateLimitBootConfigHandler = com.tencent.polaris.dubbo.ratelimit.RateLimitBootConfigHandler

0 commit comments

Comments
 (0)