vidakovic commented on code in PR #5436:
URL: https://github.com/apache/fineract/pull/5436#discussion_r2763484143


##########
fineract-command/src/main/java/org/apache/fineract/command/implementation/AsynchronousCommandExecutor.java:
##########
@@ -18,41 +18,39 @@
  */
 package org.apache.fineract.command.implementation;
 
-import java.util.List;
 import java.util.concurrent.CompletableFuture;
 import java.util.function.Supplier;
-import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.fineract.command.core.Command;
-import org.apache.fineract.command.core.CommandExecutor;
+import org.apache.fineract.command.core.CommandAuditor;
 import org.apache.fineract.command.core.CommandHandler;
-import org.apache.fineract.command.core.CommandMiddleware;
 import org.apache.fineract.command.core.CommandRouter;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Component;
 
 @Slf4j
-@RequiredArgsConstructor
 @Component
 @ConditionalOnProperty(value = "fineract.command.executor", havingValue = 
"async")
-public class AsynchronousCommandExecutor implements CommandExecutor {
+public class AsynchronousCommandExecutor extends BaseCommandExecutor {
 
-    private final List<CommandMiddleware> middlewares;
-
-    private final CommandRouter router;
+    public AsynchronousCommandExecutor(CommandRouter router, CommandAuditor 
auditor) {
+        super(router, auditor);
+    }
 
     @Override
-    public <REQ, RES> Supplier<RES> execute(Command<REQ> command) {
+    public <REQ, RES> Supplier<RES> execute(final Command<REQ> command) {
         CompletableFuture<RES> future = CompletableFuture.supplyAsync(() -> {
-            for (CommandMiddleware middleware : middlewares) {
-                middleware.invoke(command);
-            }
-
             CommandHandler<REQ, RES> handler = router.route(command);
 
             return handler.handle(command);
+        }).whenComplete((response, t) -> {
+            if (t == null) {
+                auditor.success(command, response);
+            } else {
+                auditor.fail(command, t);
+            }
         });
 
-        return future::join;
+        return () -> future.getNow(null);

Review Comment:
   Made a slight adjustment and added a comment that this needs to be improved 
before it can be used in production (no intention to do this now... just a 
proof of concept).



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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to