增加支持通过环境变量或-D读取北极星配置

pull/1095/head
yangjuanying 2 years ago
parent 8ddee3cfb9
commit 6a53cfdd7d

@ -20,10 +20,11 @@ package com.tencent.cloud.polaris.config.config;
import java.util.List; import java.util.List;
import com.tencent.cloud.polaris.config.enums.RefreshType; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import com.tencent.cloud.polaris.config.enums.RefreshType;
/** /**
* polaris config module bootstrap configs. * polaris config module bootstrap configs.
* *
@ -35,22 +36,26 @@ public class PolarisConfigProperties {
/** /**
* Whether to open the configuration center. * Whether to open the configuration center.
*/ */
@Value("${spring.cloud.polaris.config.enabled:#{'true'}}")
private boolean enabled = true; private boolean enabled = true;
/** /**
* Configuration center service address list. * Configuration center service address list.
*/ */
@Value("${spring.cloud.polaris.config.address:}")
private String address; private String address;
/** /**
* Polaris config grpc port. * Polaris config grpc port.
*/ */
@Value("${spring.cloud.polaris.config.port:#{'8093'}}")
private int port = 8093; private int port = 8093;
/** /**
* Whether to automatically update to the spring context when the configuration file. * Whether to automatically update to the spring context when the configuration file.
* is updated * is updated
*/ */
@Value("${spring.cloud.polaris.config.autoRefresh:#{'true'}}")
private boolean autoRefresh = true; private boolean autoRefresh = true;
private boolean shutdownIfConnectToConfigServerFailed = true; private boolean shutdownIfConnectToConfigServerFailed = true;

@ -24,15 +24,16 @@ import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.CollectionUtils;
import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.polaris.api.config.ConfigProvider; import com.tencent.polaris.api.config.ConfigProvider;
import com.tencent.polaris.api.config.Configuration; import com.tencent.polaris.api.config.Configuration;
import com.tencent.polaris.factory.ConfigAPIFactory; import com.tencent.polaris.factory.ConfigAPIFactory;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.CollectionUtils;
/** /**
* Properties for Polaris {@link com.tencent.polaris.client.api.SDKContext}. * Properties for Polaris {@link com.tencent.polaris.client.api.SDKContext}.
@ -45,26 +46,31 @@ public class PolarisContextProperties {
/** /**
* polaris server address. * polaris server address.
*/ */
@Value("${spring.cloud.polaris.address:}")
private String address; private String address;
/** /**
* current server local ip address. * current server local ip address.
*/ */
@Value("${spring.cloud.polaris.localIpAddress:}")
private String localIpAddress; private String localIpAddress;
/** /**
* current server local port. * current server local port.
*/ */
@Value("${spring.cloud.polaris.localPort:}")
private Integer localPort; private Integer localPort;
/** /**
* If polaris enabled. * If polaris enabled.
*/ */
@Value("${spring.cloud.polaris.enabled:#{'true'}}")
private Boolean enabled; private Boolean enabled;
/** /**
* polaris namespace. * polaris namespace.
*/ */
@Value("${spring.cloud.polaris.namespace:#{'default'}}")
private String namespace = "default"; private String namespace = "default";
/** /**

Loading…
Cancel
Save