You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/07/15 06:55:26 UTC

[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2468: SCB-2295 Governance supports time periods of string type

liubao68 commented on a change in pull request #2468:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2468#discussion_r670185129



##########
File path: governance/src/main/java/org/apache/servicecomb/governance/handler/RetryHandler.java
##########
@@ -65,21 +63,26 @@ protected Retry createProcessor(RetryPolicy policy) {
   private Retry getRetry(RetryPolicy retryPolicy) {
     LOGGER.info("applying new policy: {}", retryPolicy.toString());
 
-    List<Integer> statusList = Arrays.stream(retryPolicy.getRetryOnResponseStatus().split(","))
-        .map(Integer::parseInt).collect(Collectors.toList());
-
     RetryConfig config = RetryConfig.custom()
         .maxAttempts(retryPolicy.getMaxAttempts())
-        .retryOnResult(getPredicate(statusList))
+        .retryOnResult(getPredicate(retryPolicy.getRetryOnResponseStatus()))
         .retryExceptions(retryExtension.retryExceptions())
-        .waitDuration(Duration.ofMillis(retryPolicy.getWaitDuration()))
+        .intervalFunction(getIntervalFunction(retryPolicy))
         .build();
 
     RetryRegistry registry = RetryRegistry.of(config);
     return registry.retry(retryPolicy.getName());
   }
 
-  private Predicate<Object> getPredicate(List<Integer> statusList) {
+  private IntervalFunction getIntervalFunction(RetryPolicy retryPolicy) {
+    if (retryPolicy.getRetryStrategy().equals("RandomBackoff")) {

Review comment:
       Create a String constant in RetryPolicy, and use "RandomBackoff".equls(retryPolicy.getRetryStrategy())




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org