VictorPavfurious commented on code in PR #4281:
URL: https://github.com/apache/fineract/pull/4281#discussion_r1939188457


##########
fineract-command/src/test/java/org/apache/fineract/command/sample/web/DummyApiController.java:
##########
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.command.sample.web;
+
+import static 
org.apache.fineract.command.core.CommandConstants.COMMAND_REQUEST_ID;
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+import static 
org.springframework.http.MediaType.APPLICATION_PROBLEM_JSON_VALUE;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.command.core.CommandPipeline;
+import org.apache.fineract.command.sample.command.DummyCommand;
+import org.apache.fineract.command.sample.model.DummyRequest;
+import org.apache.fineract.command.sample.model.DummyResponse;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RequiredArgsConstructor
+@RestController
+@RequestMapping(value = "/test/dummy", consumes = APPLICATION_JSON_VALUE, 
produces = { APPLICATION_JSON_VALUE,

Review Comment:
   Are you need to consumes and produces values like APPLICATION_JSON_VALUE? I 
think in RestController has default (APPLICATION_JSON_VALUE) consumer and 
produces under hood, so it will be work fine without it😅



##########
fineract-command/src/main/java/org/apache/fineract/command/implementation/AsynchronousCommandExecutor.java:
##########
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+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.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 {
+
+    private final List<CommandMiddleware> middlewares;
+
+    private final CommandRouter router;
+
+    @Override
+    public <REQ, RES> Supplier<RES> execute(Command<REQ> command) {
+        CompletableFuture<RES> future = null;

Review Comment:
   I think this is unnecessary😅, probably be better init on single line.. I 
think it will be better at least for code style



##########
fineract-command/src/main/java/org/apache/fineract/command/core/CommandProperties.java:
##########
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.command.core;
+
+import java.io.Serial;
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.FieldNameConstants;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@Builder
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@FieldNameConstants
+@ConfigurationProperties(prefix = "fineract.command")
+public final class CommandProperties implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    @Builder.Default
+    private Boolean enabled = true;
+
+    @Builder.Default
+    private CommandExecutorType executor = CommandExecutorType.sync;
+
+    @Builder.Default
+    private Integer ringBufferSize = 1024;
+
+    public enum CommandExecutorType {

Review Comment:
   What about create all enum values on upper case? 
   And also if this enum will be use on another classes, probably necessary 
move it to separate dir...?
   I think it will the best way, because it's like standard practice



##########
fineract-command/src/test/java/org/apache/fineract/command/sample/web/DummyExceptionHandler.java:
##########
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.command.sample.web;
+
+import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
+
+import java.util.Map;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+@Slf4j
+@ControllerAdvice
+public class DummyExceptionHandler {
+
+    @ExceptionHandler(Throwable.class)
+    public ResponseEntity<Map<String, String>> 
handleRuntimeException(Throwable ex) {
+        return 
ResponseEntity.status(INTERNAL_SERVER_ERROR).body(Map.of("error", 
ex.getMessage()));

Review Comment:
   What about create universal "error class" like ApiErrorResponse and uses it 
for all body error response on our server. E.g this class will be contains 
fields as: (HttpStatus status, int status, String developerMessage, String 
errMessage, Map<String, String> properties, LocalDateTime timestamp)



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