wujimin commented on a change in pull request #546: SCB-315 Config Center 
module can't get config by DynamicPropertyFacto?
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/546#discussion_r165799372
 
 

 ##########
 File path: 
foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/AddressResolverConfig.java
 ##########
 @@ -32,58 +33,89 @@
    * @return AddressResolverOptions
    */
   public static AddressResolverOptions getAddressResover(String tag) {
+    return getAddressResover(tag, null);
+  }
+
+  /**
+   * get the target endpoints with custom address resolve config
+   * @param tag config tag, such as sc.consumer or cc.consumer
+   * @param configSource get config from special config source
+   * @return AddressResolverOptions
+   */
+  public static AddressResolverOptions getAddressResover(String tag, 
ConcurrentCompositeConfiguration configSource) {
     AddressResolverOptions addressResolverOptions = new 
AddressResolverOptions();
     addressResolverOptions
-        
.setServers(getStringListProperty(AddressResolverOptions.DEFAULT_SEACH_DOMAINS,
+        .setServers(getStringListProperty(configSource,
+            AddressResolverOptions.DEFAULT_SEACH_DOMAINS,
             "addressResolver." + tag + ".servers",
             "addressResolver.servers"));
     addressResolverOptions
-        
.setOptResourceEnabled(getBooleanProperty(AddressResolverOptions.DEFAULT_OPT_RESOURCE_ENABLED,
+        .setOptResourceEnabled(getBooleanProperty(configSource,
+            AddressResolverOptions.DEFAULT_OPT_RESOURCE_ENABLED,
             "addressResolver." + tag + ".optResourceEnabled",
             "addressResolver.optResourceEnabled"));
     addressResolverOptions
-        
.setCacheMinTimeToLive(getIntProperty(AddressResolverOptions.DEFAULT_CACHE_MIN_TIME_TO_LIVE,
+        .setCacheMinTimeToLive(getIntProperty(configSource,
+            AddressResolverOptions.DEFAULT_CACHE_MIN_TIME_TO_LIVE,
             "addressResolver." + tag + ".cacheMinTimeToLive",
             "addressResolver.cacheMinTimeToLive"));
     addressResolverOptions
-        
.setCacheMaxTimeToLive(getIntProperty(AddressResolverOptions.DEFAULT_CACHE_MAX_TIME_TO_LIVE,
+        .setCacheMaxTimeToLive(getIntProperty(configSource,
+            AddressResolverOptions.DEFAULT_CACHE_MAX_TIME_TO_LIVE,
             "addressResolver." + tag + ".cacheMaxTimeToLive",
             "addressResolver.cacheMaxTimeToLive"));
     addressResolverOptions
-        
.setCacheNegativeTimeToLive(getIntProperty(AddressResolverOptions.DEFAULT_CACHE_NEGATIVE_TIME_TO_LIVE,
+        .setCacheNegativeTimeToLive(getIntProperty(configSource,
+            AddressResolverOptions.DEFAULT_CACHE_NEGATIVE_TIME_TO_LIVE,
             "addressResolver." + tag + ".cacheNegativeTimeToLive",
             "addressResolver.cacheNegativeTimeToLive"));
     addressResolverOptions
-        
.setQueryTimeout(getIntProperty(AddressResolverOptions.DEFAULT_QUERY_TIMEOUT,
+        .setQueryTimeout(getIntProperty(configSource,
+            AddressResolverOptions.DEFAULT_QUERY_TIMEOUT,
             "addressResolver." + tag + ".queryTimeout",
             "addressResolver.queryTimeout"));
     addressResolverOptions
-        
.setMaxQueries(getIntProperty(AddressResolverOptions.DEFAULT_MAX_QUERIES,
+        .setMaxQueries(getIntProperty(configSource,
+            AddressResolverOptions.DEFAULT_MAX_QUERIES,
             "addressResolver." + tag + ".maxQueries",
             "addressResolver.maxQueries"));
     addressResolverOptions
-        .setRdFlag(getBooleanProperty(AddressResolverOptions.DEFAULT_RD_FLAG,
+        .setRdFlag(getBooleanProperty(configSource,
+            AddressResolverOptions.DEFAULT_RD_FLAG,
             "addressResolver." + tag + ".rdFlag",
             "addressResolver.rdFlag"));
     addressResolverOptions
-        
.setSearchDomains(getStringListProperty(AddressResolverOptions.DEFAULT_SEACH_DOMAINS,
+        .setSearchDomains(getStringListProperty(configSource,
+            AddressResolverOptions.DEFAULT_SEACH_DOMAINS,
             "addressResolver." + tag + ".searchDomains",
             "addressResolver.searchDomains"));
     addressResolverOptions
-        
.setNdots(getIntProperty(AddressResolverOptions.DEFAULT_CACHE_MIN_TIME_TO_LIVE,
+        .setNdots(getIntProperty(configSource,
+            AddressResolverOptions.DEFAULT_CACHE_MIN_TIME_TO_LIVE,
             "addressResolver." + tag + ".ndots",
             "addressResolver.ndots"));
     addressResolverOptions
-        
.setRotateServers(getBooleanProperty(AddressResolverOptions.DEFAULT_ROTATE_SERVERS,
+        .setRotateServers(getBooleanProperty(configSource,
+            AddressResolverOptions.DEFAULT_ROTATE_SERVERS,
             "addressResolver." + tag + ".rotateServers",
             "addressResolver.rotateServers"));
     return addressResolverOptions;
   }
 
-  private static List<String> getStringListProperty(List<String> defaultValue, 
String... keys) {
+  private static List<String> 
getStringListProperty(ConcurrentCompositeConfiguration configSource,
+      List<String> defaultValue, String... keys) {
     String property = null;
 
 Review comment:
   if configSource is null, then assign from 
DynamicPropertyFactory.getBackingConfigurationSource()
   then return Arrays.asList(configSource.getStringArray(key))

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to