-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #4824] Add HTTP Sink Connector #4837
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider supporting Webhook and HTTPS/SSL, and provide corresponding options for users in yml file.
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
OK, I will continue to improve the relevant functions. |
You may directly add more commits in this PR. |
I understand that a webhook is a callback function in HTTP (where a server sends a request to a client). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP Sink Connector would serve as a "notifier" when Webhook function enabled.
Due to Webhook's callback feature, its implementation code may differ with normal HTTP requests, which may request users to choose using normal HTTP or Webhook. If the current normal HTTP request can perform Webhook deliveries, then there's no need to add an option for it.
In order to display Webhook callback response body, you may need to store them in a memory queue, and leave a comment indicating its future use.
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
@Pil0tXia |
Are you referring to the
May you please describe in more detail the problems encountered in this part? If you're referring to the "Webhook has a lot of protocols" issue, you may check out the However, does the HTTP Sink Connector, as an HTTP Client, need to implement a special protocol? That should be the job of an HTTP Server (HTTP Source Connector). |
The way I envision or understand for a client with webhook functionality is as follows: The web client sends a request containing a ConnectRecord and a callback URL to the server, then listens on this callback URL. When changes occur on the server, data is passed to the client through this callback URL. Based on this concept, the data structure passed from the server to the client via the callback URL is unknown, thus it's not feasible to establish a uniform data processing function. I'm unsure whether my concept aligns with the intended goal.😶🌫️ |
May I ask that why do you want to process data HTTP Sink Connector received? Basically we just need to store and display it to users and it is the user who should be the one to understand the response body. |
OK, I get it, do both "storage" and "display" need to be done? Or should we store the data in the memory queue for now, and the "display" function will be implemented in the future or in other parts? |
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
You can leave an HTTP endpoint to get all Webhook delivery response results (which is a memory object as I mentioned above).
Regarding |
Regarding As for retry mechanisms, I believe that requests encountering errors at the network level can be retried, but retrying requests that have already received error status codes doesn't make much sense because servers typically respond identically to the same request. |
I would recommend this as a useful feature, but it is not a necessary task.
You've found a good point. In that case, you can put network error requests into the third queue and only retry network errors. This also applies to ordinary HTTP requests. The number of retry attempts can be set as a YAML parameter, and when its value is set to 0, it means no retries. Additionally, we can introduce another parameter that allows the user to decide whether to only retry network errors or retry all requests with non-200 status codes (such as 429, 503 indicating that server is busy, while 400, 422, 500 may get the same results). By default, only network errors are retried. |
callback url belongs to webhook function, and it isn't part of event data. So the former one is definitely better. |
Can you clarify which option it is? Because I proposed three options. In terms of code implementation, it is simpler to add the callback url to the request header. You only need to use if to determine whether you need to add this request header, without modifying the original function or creating a new function to adapt to different request bodies. |
You can add callback url both in header and body to achieve best compatibility. If you believe that only header or body is needed to add, then one of them is enough. |
The header is carried by every HTTP request, so I think passing the callback url through the header is enough. The redundant design of declaring the callback url again in the body does not seem to improve compatibility, unless faced with A server that completely ignores HTTP headers. |
@cnzakii May I ask that what do you want to put in |
...ttp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/CommonHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/connector/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
...tp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...tp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...ttp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/CommonHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...ttp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/CommonHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...ttp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/CommonHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...ttp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/CommonHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...ttp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/CommonHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
I'm very sorry, that was my mistake, I've submitted my comment and you should see it now. |
@cnzakii Never mind! It's not your fault. I personally think it is GitHub's design oversight. I might prefer not reply a conversation via Files Changed page. |
@Pil0tXia PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall design is very good, and it's highly complete. It's clear that a lot of thought and effort has been put into it. I've only suggested some minor modifications.
...ctor-http/src/main/java/org/apache/eventmesh/connector/http/sink/config/HttpRetryConfig.java
Outdated
Show resolved
Hide resolved
eventmesh-connectors/eventmesh-connector-http/src/main/resources/sink-config.yml
Outdated
Show resolved
Hide resolved
eventmesh-connectors/eventmesh-connector-http/src/main/resources/sink-config.yml
Outdated
Show resolved
Hide resolved
...ctor-http/src/main/java/org/apache/eventmesh/connector/http/sink/handle/HttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...connector-http/src/main/java/org/apache/eventmesh/connector/http/sink/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
...ttp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/CommonHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...tp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...tp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...tp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...tp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick and brief review. I will see changes to Retry tomorrow.
...connector-http/src/main/java/org/apache/eventmesh/connector/http/sink/HttpSinkConnector.java
Outdated
Show resolved
Hide resolved
...tp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java
Show resolved
Hide resolved
...tp/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/handle/RetryHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/handle/RetryHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...http/src/main/java/org/apache/eventmesh/connector/http/sink/handle/RetryHttpSinkHandler.java
Outdated
Show resolved
Hide resolved
...ctor-http/src/main/java/org/apache/eventmesh/connector/http/sink/data/HttpConnectRecord.java
Outdated
Show resolved
Hide resolved
...ctor-http/src/main/java/org/apache/eventmesh/connector/http/sink/data/HttpConnectRecord.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The completion of this HTTP Sink Connector is truly remarkable. I have a strong feeling it will become one of the most frequently used connectors among EventMesh users.
I sincerely invite you to join in the development of Webhook support for the HTTP Source Connector. With your experience with the HTTP Sink Connector, I believe you are more than capable of handling this feature, and can significantly alleviate the review workload for the community.
Documentation can be submitted later to the https://github.com/apache/eventmesh-site repository. It would be wonderful if you could showcase the extensive features of the EventMesh HTTP Sink Connector to the users there.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4837 +/- ##
============================================
+ Coverage 16.20% 16.43% +0.22%
- Complexity 1710 1817 +107
============================================
Files 857 910 +53
Lines 30883 32351 +1468
Branches 2685 2776 +91
============================================
+ Hits 5005 5317 +312
- Misses 25410 26519 +1109
- Partials 468 515 +47 ☔ View full report in Codecov by Sentry. |
Thank you very much for your help during this period. Without your assistance, it would have been difficult for me to complete the Http Sink Connector to this extent.
After this PR is successfully merged, I will complete this work.
I am very willing to continue contributing to the community. After I complete all the work on the Http Sink Connector, I will attempt to finish it (if the issue hasn't been assigned yet). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #4824
Motivation
[Feature] Add HTTP Sink Connector #4824
Modifications
HttpSinkConnectorTest
to test the functionality of the HTTP Sink Connector.Documentation