Pil0tXia commented on code in PR #4272:
URL: https://github.com/apache/eventmesh/pull/4272#discussion_r1272501364
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryRecommendEventMeshHandler.java:
##########
@@ -38,30 +38,61 @@
import lombok.extern.slf4j.Slf4j;
/**
- * query recommend eventmesh
+ * This class handles the HTTP requests of {@code /eventMesh/recommend}
endpoint,
+ * which is used to calculate and return the recommended EventMesh server node
to the client
+ * based on the provided {@code group} and {@code purpose} parameters.
+ * <p>
+ * Parameters:
+ * <ul>
+ * <li>client group: {@code group} | Example: {@code
EventmeshTestGroup}</li>
+ * <li>client purpose: {@code purpose} | Example: {@code sub}</li>
+ * </ul>
+ * It uses an {@link EventMeshRecommendStrategy} which is implemented by
{@link EventMeshRecommendImpl}
+ * to calculate the recommended EventMesh server node.
+ *
+ * @see AbstractHttpHandler
*/
@Slf4j
@EventHttpHandler(path = "/eventMesh/recommend")
public class QueryRecommendEventMeshHandler extends AbstractHttpHandler {
private final EventMeshTCPServer eventMeshTCPServer;
+ /**
+ * Constructs a new instance with the provided server instance and HTTP
handler manager.
+ *
+ * @param eventMeshTCPServer the TCP server instance of EventMesh
+ * @param httpHandlerManager Manages the registration of {@linkplain
com.sun.net.httpserver.HttpHandler HttpHandler}
+ * for an {@link
com.sun.net.httpserver.HttpServer HttpServer}.
+ */
public QueryRecommendEventMeshHandler(EventMeshTCPServer
eventMeshTCPServer, HttpHandlerManager httpHandlerManager) {
super(httpHandlerManager);
this.eventMeshTCPServer = eventMeshTCPServer;
}
+ /**
+ * Handles the HTTP requests by calculating a recommended EventMesh server
node.
+ * <p>
+ * This method is an implementation of {@linkplain
com.sun.net.httpserver.HttpHandler#handle(HttpExchange) HttpHandler.handle()}.
+ *
+ * @param httpExchange the exchange containing the request from the client
and used to send the response
+ * @throws IOException if an I/O error occurs while handling the request
+ */
@Override
public void handle(HttpExchange httpExchange) throws IOException {
String result = "";
try (OutputStream out = httpExchange.getResponseBody()) {
+ // Check whether the registry is enabled
Review Comment:
For now, I am very familiar with this portion of the code, and I can
understand it without comments. However, for new contributors, these comments
will undoubtedly be helpful. The comments provide clearer delineation of the
functionality in long stretches of code, making it more pleasing to the eye.
Nevertheless, I have removed some relatively simple comments in
https://github.com/apache/eventmesh/pull/4272/commits/b2d4ca8118b2d53875f76cd8203d0794debf3fbc.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]