Merge pull request #36 from xiaoyao1999hn/main

the server address only support one ip #35
pull/41/head
Haotian Zhang 3 years ago committed by GitHub
commit fe45c4f299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,6 +37,8 @@ import org.springframework.context.annotation.Bean;
@EnableConfigurationProperties(PolarisContextProperties.class)
public class PolarisContextConfiguration {
private static final String ADDRESS_SEPARATOR = ",";
@Bean(name = "polarisContext", initMethod = "init", destroyMethod = "destroy")
@ConditionalOnMissingBean
public SDKContext polarisContext(PolarisContextProperties properties) throws PolarisException {
@ -57,11 +59,18 @@ public class PolarisContextConfiguration {
@Override
public void modify(ConfigurationImpl configuration) {
if (!StringUtils.isBlank(properties.getAddress())) {
URI uri = URI.create(properties.getAddress());
List<String> addresses = new ArrayList<>();
addresses.add(uri.getAuthority());
configuration.getGlobal().getServerConnector().setAddresses(addresses);
configuration.getGlobal().getServerConnector().setAddresses(getAddressList(properties.getAddress()));
}
}
private List<String> getAddressList(String addressInfo) {
List<String> addressList = new ArrayList<>();
String[] addresses = addressInfo.split(ADDRESS_SEPARATOR);
for (String address : addresses) {
URI uri = URI.create(address.trim());
addressList.add(uri.getAuthority());
}
return addressList;
}
}

Loading…
Cancel
Save