diff --git a/docs/design-document/03-connect/02-http-connector.md b/docs/design-document/03-connect/02-http-connector.md index 807d9ed40..55a77b54b 100644 --- a/docs/design-document/03-connect/02-http-connector.md +++ b/docs/design-document/03-connect/02-http-connector.md @@ -5,12 +5,15 @@ ### Configuration Before using HTTP source connector, you need to configure the server. + - Please configure `sourceEnable` to `true` in `/resource/server-config.yml` to enable source functionality. -- Please configure the source connector in `/resource/source-config.yml`, only the configuration under `connectorConfig` is described here: - - `connectorName`, name of the connector. - - (required) `path`, path of the API. - - (required) `port`, port of the API. - - `idleTimeout`, idle TCP connection timeout in seconds. A connection will timeout and be closed if no data is received nor sent within the `idleTimeout` seconds. The default is 0, which means don't timeout. +- Please configure the source connector in `/resource/source-config.yml`, only the configuration under `connectorConfig` + is described here: + - `connectorName`, name of the connector. + - (required) `path`, path of the API. + - (required) `port`, port of the API. + - `idleTimeout`, idle TCP connection timeout in seconds. A connection will timeout and be closed if no data is + received nor sent within the `idleTimeout` seconds. The default is 0, which means don't timeout. ### Startup @@ -25,15 +28,16 @@ You can send messages to the source connector via HTTP. ```yaml connectorConfig: - connectorName: httpSource - path: /test - port: 3755 - idleTimeout: 5 + connectorName: httpSource + path: /test + port: 3755 + idleTimeout: 5 ``` The above example configures a URL `http://localhost:3755/test` in `source-config.yml`. -You can send messages in `binary` mode or `structured` mode as specified in [cloudevent-spec](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/bindings/http-protocol-binding.md). +You can send messages in `binary` mode or `structured` mode as specified +in [cloudevent-spec](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/bindings/http-protocol-binding.md). Here are two examples: @@ -66,13 +70,15 @@ curl --location --request POST 'http://localhost:3755/test' \ }' ``` - - ## HTTP Sink Connector The HTTP sink connector has two modes: common and webhook. -First of all, either mode has the basic function of sinkConnector, which is to send a message to the target HTTP server. When the response is received from the HTTP server, the common mode only cares about the status code of the response to determine whether it was sent successfully, while the webook mode not only cares about whether it was sent successfully or not, but also stores the data of the response (called the callback data) and provides callback data exposure services to the outside world. +First of all, either mode has the basic function of sinkConnector, which is to send a message to the target HTTP server. +When the response is received from the HTTP server, the common mode only cares about the status code of the response to +determine whether it was sent successfully, while the webook mode not only cares about whether it was sent successfully +or not, but also stores the data of the response (called the callback data) and provides callback data exposure services +to the outside world. The specific differences between the two are as follows: @@ -82,9 +88,8 @@ The specific differences between the two are as follows: - Processing of response results - The common mode only cares about the status code of the response, while the webhook mode will also store the callback data and provide callback data exposure services to the public. - - + The common mode only cares about the status code of the response, while the webhook mode will also store the callback + data and provide callback data exposure services to the public. ### Configuration @@ -92,7 +97,8 @@ Before using the HTTP sink connector, you need to configure the sink. - Please configure `sinkEnable` to true in `/resource/server-config.yml` to enable sink function. -- Please configure the sink connector in `/resource/sink-config.yml`, only the configuration under `connectorConfig` is described here: +- Please configure the sink connector in `/resource/sink-config.yml`, only the configuration under `connectorConfig` is + described here: The simplest configuration of the common mode: @@ -117,36 +123,34 @@ Before using the HTTP sink connector, you need to configure the sink. All configurations for the HTTP sink connector are listed below: -| Field | Type | Required or not | Clarification | Remark | -| ------------------------------- | ------- | ------------------ | ---------------------------------------------------------- | ------------------------------------------------------------ | -| connectorName | String | yes | Connector Name | | -| urls | List | yes | List of URLs to receive messages | The default port is 80 for HTTP protocol and 443 for HTTPS protocol
The legal URL format are:
http://127.0.0.1:8987/test
http://127.0.0.1/test
https://example.com:4943/test
https://example.com/test
| -| keepAlive | Boolean | no | Whether to use HTTP persistent connection | Default: true | -| keepAliveTimeout | Integer | no | HTTP persistent connection timeout | Unit: ms,default: 60000 | -| connectionTimeout | Integer | no | TCP connection timeout | Unit: ms,default: 5000 | -| idleTimeout | Integer | no | TCP idle timeout | Unit: ms,default: 5000(common), 15000(webhook) | -| maxConnectionPoolSize | Integer | no | Maximum number of HTTP connections for the client | Default: 5 | -| retryConfig | Object | | Configuration of the retry mechanism | | -| retryConfig.maxRetries | Integer | no | Maximum number of retries | Does not include first attempt, default: 2 | -| retryConfig.interval | Integer | no | Retry interval | Unit: ms, default: 2000 | -| retryConfig.retryOnNonSuccess | Boolean | no | Whether to retry requests that receive a non-2xx response | Default: false, retries only network level error requests | -| webhookConfig | Object | | Configuration of Webhook Mode | | -| webhookConfig.activate | Boolean | no | Whether to enable Webhook mode | Default: false | +| Field | Type | Required or not | Clarification | Remark | +|---------------------------------|---------|--------------------|------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| connectorName | String | yes | Connector Name | | +| urls | List | yes | List of URLs to receive messages | The default port is 80 for HTTP protocol and 443 for HTTPS protocol
The legal URL format are:
http://127.0.0.1:8987/test
http://127.0.0.1/test
https://example.com:4943/test
https://example.com/test
| +| keepAlive | Boolean | no | Whether to use HTTP persistent connection | Default: true | +| keepAliveTimeout | Integer | no | HTTP persistent connection timeout | Unit: ms,default: 60000 | +| connectionTimeout | Integer | no | TCP connection timeout | Unit: ms,default: 5000 | +| idleTimeout | Integer | no | TCP idle timeout | Unit: ms,default: 5000(common), 15000(webhook) | +| maxConnectionPoolSize | Integer | no | Maximum number of HTTP connections for the client | Default: 5 | +| retryConfig | Object | | Configuration of the retry mechanism | | +| retryConfig.maxRetries | Integer | no | Maximum number of retries | Does not include first attempt, default: 2 | +| retryConfig.interval | Integer | no | Retry interval | Unit: ms, default: 2000 | +| retryConfig.retryOnNonSuccess | Boolean | no | Whether to retry requests that receive a non-2xx response | Default: false, retries only network level error requests | +| webhookConfig | Object | | Configuration of Webhook Mode | | +| webhookConfig.activate | Boolean | no | Whether to enable Webhook mode | Default: false | | webhookConfig.exportPath | String | no | Callback data exposure path | Default: /export
The request method is fixed to GET
Request Parameters:
type:peek (default value, get data)/poll (get and delete data)
pageNum: must be greater than 0 when type is peek, invalid when type is poll
pageSize: must be greater than 0 | -| webhookConfig.port | Integer | Yes (when enabled) | Callback data exposure port | | -| webhookConfig.serverIdleTimeout | Integer | no | TCP idle timeout length for servers exposing callback data | Unit: ms, default: 5000 | -| webhookConfig.maxStorageSize | Integer | no | Store the maximum value of the callback data queue | Default: 5000 | - - +| webhookConfig.port | Integer | Yes (when enabled) | Callback data exposure port | | +| webhookConfig.serverIdleTimeout | Integer | no | TCP idle timeout length for servers exposing callback data | Unit: ms, default: 5000 | +| webhookConfig.maxStorageSize | Integer | no | Store the maximum value of the callback data queue | Default: 5000 | ### Startup 1. start EventMesh Runtime 2. start eventmesh-connector-http -Once that's done, send a message to the EventMesh, and then your message will happen to the target HTTP server via an HTTP request. If webhook mode is enabled, an HTTP server will also be opened at the same time to provide callback data exposure to the outside world. - - +Once that's done, send a message to the EventMesh, and then your message will happen to the target HTTP server via an +HTTP request. If webhook mode is enabled, an HTTP server will also be opened at the same time to provide callback data +exposure to the outside world. ### Data Format @@ -160,48 +164,52 @@ The data format of the message sent by the HTTP sink connector is as follows: ```json { - "type": "httpSink.http.webhook", - "time": "2024-05-09T22:27:02.028", - "uuid": "951d88ee-2503-4df3-a1dd-6e4a6a1c3d3b", - "eventId": "httpSink.http.webhook-0", - "data": ${ConnectRecord} + "type": "httpSink.http.webhook", + "time": "2024-05-09T22:27:02.028", + "uuid": "951d88ee-2503-4df3-a1dd-6e4a6a1c3d3b", + "eventId": "httpSink.http.webhook-0", + "data": ${ConnectRecord} } ``` -When webhook mode is enabled, an HTTP server is also enabled to provide callback data exposure to the outside world. The format of the callback data is as follows: +When webhook mode is enabled, an HTTP server is also enabled to provide callback data exposure to the outside world. The +format of the callback data is as follows: - pageNum: current page number - pageSize: size per page - pageItems: the callback data array obtained - The meaning of the fields of pageItem is as follows: - - data: callback data returned from the callback server - - metadata: metadata, the fields have the following meanings: - - url: the URL to get the callback data - - code: the status code of the response to the request callback data, or -1 if a network level error occurred (response could not be received). - - message: response information from the request callback data, or exception information if a network level error occurred (response could not be received). - - uuid: a unique request identifier for the callback data, corresponding to the uuid carried in the message sent above. - - receivedTime: response time for requesting callback data - - retryNum: number of retries - - retriedBy: record the uuid of the request being retried if a retry is sent, otherwise null + - data: callback data returned from the callback server + - metadata: metadata, the fields have the following meanings: + - url: the URL to get the callback data + - code: the status code of the response to the request callback data, or -1 if a network level error occurred ( + response could not be received). + - message: response information from the request callback data, or exception information if a network level + error occurred (response could not be received). + - uuid: a unique request identifier for the callback data, corresponding to the uuid carried in the message sent + above. + - receivedTime: response time for requesting callback data + - retryNum: number of retries + - retriedBy: record the uuid of the request being retried if a retry is sent, otherwise null ```json { - "pageNum": 1, - "pageSize": 10, - "pageItems": [ - { - "data": "callbackData", - "metadata": { - "url": "http://127.0.0.1:8987/test", - "code": 200, - "message": "OK", - "receivedTime": "2024-05-09 22:53:21.556", - "uuid": "fba29061-1a1f-4482-9c83-43ba4e0bcf3f", - "retriedBy": null, - "retryNum": 0 - } - } - ] + "pageNum": 1, + "pageSize": 10, + "pageItems": [ + { + "data": "callbackData", + "metadata": { + "url": "http://127.0.0.1:8987/test", + "code": 200, + "message": "OK", + "receivedTime": "2024-05-09 22:53:21.556", + "uuid": "fba29061-1a1f-4482-9c83-43ba4e0bcf3f", + "retriedBy": null, + "retryNum": 0 + } + } + ] } ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/design-document/03-connect/02-http-connector.md b/i18n/zh/docusaurus-plugin-content-docs/current/design-document/03-connect/02-http-connector.md index 4d2cf09b5..710e47b8b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/design-document/03-connect/02-http-connector.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/design-document/03-connect/02-http-connector.md @@ -25,10 +25,10 @@ ```yaml connectorConfig: - connectorName: httpSource - path: /test - port: 3755 - idleTimeout: 5 + connectorName: httpSource + path: /test + port: 3755 + idleTimeout: 5 ``` 上述的例子在`source-config.yml`中配置了一个 URL `http://localhost:3755/test`. @@ -66,8 +66,6 @@ curl --location --request POST 'http://localhost:3755/test' \ }' ``` - - ## HTTP Sink Connector HTTP sink connector 拥有两种模式:common 和 webhook。 @@ -82,8 +80,6 @@ HTTP sink connector 拥有两种模式:common 和 webhook。 common模式只关心响应的状态码,而webhook模式还会存储回调数据,并对外提供回调数据暴露服务。 - - ### 配置 使用 HTTP sink connector 前,需要进行 sink 的配置。 @@ -113,42 +109,35 @@ HTTP sink connector 拥有两种模式:common 和 webhook。 port: 8988 ``` - - HTTP sink connector 的所有配置如下: -| 属性 | 类型 | 是否必填 | 说明 | 备注 | -| ------------------------------- | ------- | ------------ | ------------------------------------- | ------------------------------------------------------------ | -| connectorName | String | 是 | connector名称 | | -| urls | List | 是 | 接收消息的URL列表 | HTTP协议默认端口为80,HTTPS协议则为443
合法URL格式为:
http://127.0.0.1:8987/test
http://127.0.0.1/test
https://example.com:4943/test
https://example.com/test
| -| keepAlive | Boolean | 否 | 是否使用HTTP持久连接 | 默认:true | -| keepAliveTimeout | Integer | 否 | HTTP持久连接超时时长 | 单位:ms,默认:60000 | -| connectionTimeout | Integer | 否 | TCP连接超时时长 | 单位:ms,默认:5000 | -| idleTimeout | Integer | 否 | TCP空闲超时时长 | 单位:ms,默认:5000(common),15000(webhook) | -| maxConnectionPoolSize | Integer | 否 | 客户端的最大HTTP连接数 | 默认:5 | -| retryConfig | Object | | 重试机制的相关配置 | | -| retryConfig.maxRetries | Integer | 否 | 最大重试次数 | 不包含首次尝试,默认:2 | -| retryConfig.interval | Integer | 否 | 重试间隔 | 单位:ms,默认:2000 | -| retryConfig.retryOnNonSuccess | Boolean | 否 | 是否重试收到非2xx响应的请求 | 默认:false,仅重试网络层面的错误请求 | -| webhookConfig | Object | | Webhook模式的相关配置 | | -| webhookConfig.activate | Boolean | 否 | 是否启用Webhook模式 | 默认:false | -| webhookConfig.exportPath | String | 否 | 回调数据暴露路径 | 默认:/export
请求方式固定为GET
请求参数有
type:peek(默认值,获取数据)/poll(获取并删除数据)
pageNum:当type为peek时,必须大于0,当type为poll时,该参数无效
pageSize:必须大于0 | -| webhookConfig.port | Integer | 是(启用时) | 回调数据暴露端口 | | -| webhookConfig.serverIdleTimeout | Integer | 否 | 暴露回调数据的服务器的TCP空闲超时时长 | 单位:ms,默认:5000 | -| webhookConfig.maxStorageSize | Integer | 否 | 存储回调数据队列的最大值 | 默认:5000 | - - +| 属性 | 类型 | 是否必填 | 说明 | 备注 | +|---------------------------------|---------|--------|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| connectorName | String | 是 | connector名称 | | +| urls | List | 是 | 接收消息的URL列表 | HTTP协议默认端口为80,HTTPS协议则为443
合法URL格式为:
http://127.0.0.1:8987/test
http://127.0.0.1/test
https://example.com:4943/test
https://example.com/test
| +| keepAlive | Boolean | 否 | 是否使用HTTP持久连接 | 默认:true | +| keepAliveTimeout | Integer | 否 | HTTP持久连接超时时长 | 单位:ms,默认:60000 | +| connectionTimeout | Integer | 否 | TCP连接超时时长 | 单位:ms,默认:5000 | +| idleTimeout | Integer | 否 | TCP空闲超时时长 | 单位:ms,默认:5000(common),15000(webhook) | +| maxConnectionPoolSize | Integer | 否 | 客户端的最大HTTP连接数 | 默认:5 | +| retryConfig | Object | | 重试机制的相关配置 | | +| retryConfig.maxRetries | Integer | 否 | 最大重试次数 | 不包含首次尝试,默认:2 | +| retryConfig.interval | Integer | 否 | 重试间隔 | 单位:ms,默认:2000 | +| retryConfig.retryOnNonSuccess | Boolean | 否 | 是否重试收到非2xx响应的请求 | 默认:false,仅重试网络层面的错误请求 | +| webhookConfig | Object | | Webhook模式的相关配置 | | +| webhookConfig.activate | Boolean | 否 | 是否启用Webhook模式 | 默认:false | +| webhookConfig.exportPath | String | 否 | 回调数据暴露路径 | 默认:/export
请求方式固定为GET
请求参数有
type:peek(默认值,获取数据)/poll(获取并删除数据)
pageNum:当type为peek时,必须大于0,当type为poll时,该参数无效
pageSize:必须大于0 | +| webhookConfig.port | Integer | 是(启用时) | 回调数据暴露端口 | | +| webhookConfig.serverIdleTimeout | Integer | 否 | 暴露回调数据的服务器的TCP空闲超时时长 | 单位:ms,默认:5000 | +| webhookConfig.maxStorageSize | Integer | 否 | 存储回调数据队列的最大值 | 默认:5000 | ### 启动 1. 启动 EventMesh Runtime 2. 启动 eventmesh-connector-http -完成之后,向 EventMesh 发送消息,然后你的消息就会通过HTTP请求发生给目标HTTP服务器了。如果启用webhook模式,则还会同时开启一个 HTTP 服务器对外提供回调数据暴露服务。 - - - - +完成之后,向 EventMesh 发送消息,然后你的消息就会通过HTTP请求发生给目标HTTP服务器了。如果启用webhook模式,则还会同时开启一个 +HTTP 服务器对外提供回调数据暴露服务。 ### 数据格式 @@ -162,50 +151,48 @@ HTTP sink connector 发送消息的数据格式如下: ```json { - "type": "httpSink.http.webhook", - "time": "2024-05-09T22:27:02.028", - "uuid": "951d88ee-2503-4df3-a1dd-6e4a6a1c3d3b", - "eventId": "httpSink.http.webhook-0", - "data": ${ConnectRecord} + "type": "httpSink.http.webhook", + "time": "2024-05-09T22:27:02.028", + "uuid": "951d88ee-2503-4df3-a1dd-6e4a6a1c3d3b", + "eventId": "httpSink.http.webhook-0", + "data": ${ConnectRecord} } ``` - - 启用webhook模式时,则还会同时开启一个 HTTP 服务器对外提供回调数据暴露服务。获取的回调数据格式如下: - pageNum:当前页数 - pageSize:每页的大小 - pageItems:获取的回调数据数组 - pageItem的字段含义如下: - - data:从回调服务器返回的回调数据 - - metadata:元数据,字段含义如下: - - url: 获取回调数据的URL - - code:请求回调数据得到的响应状态码,如果发生的网络层面的错误(无法收到响应),则为-1 - - message:请求回调数据得到的响应信息,如果发生的网络层面的错误(无法收到响应),则为相关异常信息 - - uuid:请求回调数据的唯一请求标识,和上面发送消息时所携带的uuid一一对应 - - receivedTime:请求回调数据得到的响应时间 - - retryNum:重试次数 - - retriedBy:如果发送重试,则记录被重试的请求的uuid,否则为null + - data:从回调服务器返回的回调数据 + - metadata:元数据,字段含义如下: + - url: 获取回调数据的URL + - code:请求回调数据得到的响应状态码,如果发生的网络层面的错误(无法收到响应),则为-1 + - message:请求回调数据得到的响应信息,如果发生的网络层面的错误(无法收到响应),则为相关异常信息 + - uuid:请求回调数据的唯一请求标识,和上面发送消息时所携带的uuid一一对应 + - receivedTime:请求回调数据得到的响应时间 + - retryNum:重试次数 + - retriedBy:如果发送重试,则记录被重试的请求的uuid,否则为null ```json { - "pageNum": 1, - "pageSize": 10, - "pageItems": [ - { - "data": "callbackData", - "metadata": { - "url": "http://127.0.0.1:8987/test", - "code": 200, - "message": "OK", - "receivedTime": "2024-05-09 22:53:21.556", - "uuid": "fba29061-1a1f-4482-9c83-43ba4e0bcf3f", - "retriedBy": null, - "retryNum": 0 - } - } - ] + "pageNum": 1, + "pageSize": 10, + "pageItems": [ + { + "data": "callbackData", + "metadata": { + "url": "http://127.0.0.1:8987/test", + "code": 200, + "message": "OK", + "receivedTime": "2024-05-09 22:53:21.556", + "uuid": "fba29061-1a1f-4482-9c83-43ba4e0bcf3f", + "retriedBy": null, + "retryNum": 0 + } + } + ] } ```