cnzakii commented on code in PR #4837: URL: https://github.com/apache/eventmesh/pull/4837#discussion_r1581997767
########## eventmesh-connectors/eventmesh-connector-http/src/main/java/org/apache/eventmesh/connector/http/sink/handle/HttpSinkHandler.java: ########## @@ -17,27 +17,57 @@ package org.apache.eventmesh.connector.http.sink.handle; +import org.apache.eventmesh.connector.http.sink.data.HttpConnectRecord; import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord; +import java.net.URI; + +import io.vertx.core.Future; +import io.vertx.core.buffer.Buffer; +import io.vertx.ext.web.client.HttpResponse; + /** - * Any class that needs to process ConnectRecord via HTTP needs to implement this interface. + * Interface for handling ConnectRecords via HTTP or HTTPS. Classes implementing this interface are responsible for processing ConnectRecords by + * sending them over HTTP or HTTPS, with additional support for handling multiple requests and asynchronous processing. + * + * <p>Any class that needs to process ConnectRecords via HTTP or HTTPS should implement this interface. + * Implementing classes must provide implementations for the {@link #start()}, {@link #multiHandle(ConnectRecord)}, + * {@link #handle(URI, HttpConnectRecord)}, and {@link #stop()} methods.</p> + * + * <p>Implementing classes should ensure thread safety and handle HTTP/HTTPS communication efficiently. + * The {@link #start()} method initializes any necessary resources for HTTP/HTTPS communication. + * The {@link #multiHandle(ConnectRecord)} method processes a ConnectRecord multiple times by sending it over HTTP or HTTPS. + * The {@link #handle(URI, HttpConnectRecord)} method processes a single ConnectRecord by sending it over HTTP or HTTPS to the specified URL. + * The {@link #stop()} method releases any resources used for HTTP/HTTPS communication.</p> + * + * <p>It's recommended to handle exceptions gracefully within the {@link #handle(URI, HttpConnectRecord)} method + * to prevent message loss or processing interruptions.</p> */ public interface HttpSinkHandler { /** - * start the handler + * Initializes the HTTP/HTTPS handler. This method should be called before using the handler. */ void start(); /** - * Handle the ConnectRecord. + * Processes the ConnectRecord multiple times. * * @param record the ConnectRecord to handle */ - void handle(ConnectRecord record); + void multiHandle(ConnectRecord record); Review Comment: In fact, I'm not entirely satisfied with the method names `handle` and `multiHandle`. I consider the `multiHandle` method as the sole entry point for the `HttpSinkHandler` to process `ConnectRecord`, while the handle method seems more like a processing chain for `ConnectRecord` data. Any `HttpSinkHandler` can "introduce" other `HttpSinkHandler` either through inheritance (like `WebhookHttpHandler`) or using the Decorator pattern (like `RetryHttpHandler`), executing the processing logic of other `HttpSinkHandlers` within the `handle` method and selecting to add its own processing logic. Do you have any good naming suggestions? -- 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: issues-unsubscr...@eventmesh.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@eventmesh.apache.org For additional commands, e-mail: issues-h...@eventmesh.apache.org