liubao68 commented on a change in pull request #1017: [SCB-1056] put provider 
flow control logic in front
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1017#discussion_r238062026
 
 

 ##########
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java
 ##########
 @@ -150,6 +167,39 @@ protected void scheduleInvocation() {
     });
   }
 
+  private Holder<Boolean> checkQpsFlowControl(OperationMeta operationMeta) {
+    Holder<Boolean> qpsFlowControlReject = new Holder<>(false);
+    Handler providerQpsFlowControlHandler = 
findQpsFlowControlHandler(operationMeta);
+    if (null != providerQpsFlowControlHandler) {
+      try {
+        providerQpsFlowControlHandler.handle(invocation, response -> {
+          qpsFlowControlReject.value = true;
+          produceProcessor = ProduceProcessorManager.JSON_PROCESSOR;
+          sendResponse(response);
+        });
+      } catch (Exception e) {
+        LOGGER.error("failed to execute ProviderQpsFlowControlHandler", e);
+        qpsFlowControlReject.value = true;
+        sendFailResponse(e);
+      }
+    }
+    return qpsFlowControlReject;
 
 Review comment:
   I mean "qpsFlowControlReject.value = true;" may executed after this method 
return because "handle" is executed async. Although your code works as you 
expected in this situation. It's not good code.  

----------------------------------------------------------------
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