liubao68 commented on a change in pull request #744: [SCB-627] Client Request 
Timeout support for operation/schema/service level
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/744#discussion_r192084714
 
 

 ##########
 File path: 
core/src/main/java/org/apache/servicecomb/core/transport/AbstractTransport.java
 ##########
 @@ -160,4 +161,83 @@ public Object parseAddress(String address) {
     }
     return new URIEndpointObject(address);
   }
+
+  /**
+   * Handles the request timeout configurations.
+   * 
+   * @param invocation
+   *            invocation of request
+   * @return configuration value
+   */
+  public static long getReqTimeout(Invocation invocation) {
+    long value = 0;
+    String config;
+
+    // get the config base on priority. 
operationName-->schema-->service-->global
+    String operationName = invocation.getOperationName();
+    String schema = invocation.getSchemaId();
+    String serviceName = invocation.getMicroserviceName();
+
+    config = CONSUMER_REQUEST_TIMEOUT + "." + serviceName + "." + schema + "." 
+ operationName;
+    value = getConfigValue(config);
+    if ((value != REQUEST_TIMEOUT_CFG_FAIL)) {
+      return value;
+    }
+
+    config = CONSUMER_REQUEST_TIMEOUT + "." + serviceName + "." + schema;
+    value = getConfigValue(config);
+    if ((value != REQUEST_TIMEOUT_CFG_FAIL)) {
+      return value;
+    }
+
+    config = CONSUMER_REQUEST_TIMEOUT + "." + serviceName;
+    value = getConfigValue(config);
+    if ((value != REQUEST_TIMEOUT_CFG_FAIL)) {
+      return value;
+    }
+
+    value = getConfigValue(CONSUMER_REQUEST_TIMEOUT);
+    if ((value != REQUEST_TIMEOUT_CFG_FAIL)) {
+      return value;
+    }
+    return DEFAULT_TIMEOUT_MILLIS;
+  }
+
+  /**
+   * Get the configuration value
+   * @param config config parameter
+   * @return long value
+   */
+  private static long getConfigParam(String config, long defaultValue) {
 
 Review comment:
   Maybe you can refer to 
https://github.com/apache/incubator-servicecomb-java-chassis/blob/master/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
 to make this method simpler. 
   
   And you do not need to cache configure center values, since 
DynamicPropertyFactory.getInstance().getLongProperty will get the latest value 
for you. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to