This is an automated email from the ASF dual-hosted git repository.

mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new be8fcc93c [ISSUE #4656] Documentation Needed for 
eventmesh-connector-http
be8fcc93c is described below

commit be8fcc93c61ad758bf4c9a7b51db575dee40966d
Author: Fungx <[email protected]>
AuthorDate: Sat Dec 16 18:41:57 2023 +0800

    [ISSUE #4656] Documentation Needed for eventmesh-connector-http
---
 .../eventmesh-connector-http/README.md             | 62 ++++++++++++++++++++++
 .../eventmesh-connector-http/README_CN.md          | 61 +++++++++++++++++++++
 2 files changed, 123 insertions(+)

diff --git a/eventmesh-connectors/eventmesh-connector-http/README.md 
b/eventmesh-connectors/eventmesh-connector-http/README.md
new file mode 100644
index 000000000..229dd3c59
--- /dev/null
+++ b/eventmesh-connectors/eventmesh-connector-http/README.md
@@ -0,0 +1,62 @@
+# eventmesh-connector-http
+
+## 1 HTTP Source Connector
+
+### 1.1 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.
+
+### 1.2 Startup
+
+1. start eventmesh-runtime
+2. start eventmesh-connector-http
+
+When finished, the HTTP source connector will act as an HTTP server.
+
+### 1.3 Sending messages
+You can send messages to the source connector via HTTP.
+```yaml
+connectorConfig:
+    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).
+
+Here are two examples:
+
+1. Sending a message in `binary` mode.
+```shell
+curl --location --request POST 'http://localhost:3755/test' \
+--header 'ce-id: 1' \
+--header 'ce-specversion: 1.0' \
+--header 'ce-type: com.example.someevent' \
+--header 'ce-source: /mycontext' \
+--header 'ce-subject: test_topic' \
+--header 'Content-Type: text/plain' \
+--data-raw 'testdata'
+```
+
+2. Sending a message in `structured` mode.
+```shell
+curl --location --request POST 'http://localhost:3755/test' \
+--header 'Content-Type: application/cloudevents+json' \
+--data-raw '{
+    "id": "1",
+    "specversion": "1.0",
+    "type": "com.example.someevent",
+    "source": "/mycontext",
+    "subject":"test_topic",
+    "datacontenttype":"text/plain",
+    "data": "testdata"
+}'
+```
diff --git a/eventmesh-connectors/eventmesh-connector-http/README_CN.md 
b/eventmesh-connectors/eventmesh-connector-http/README_CN.md
new file mode 100644
index 000000000..52843b78c
--- /dev/null
+++ b/eventmesh-connectors/eventmesh-connector-http/README_CN.md
@@ -0,0 +1,61 @@
+# eventmesh-connector-http
+
+## 1 HTTP Source Connector
+
+### 1.1 配置
+使用 HTTP source connector 前,需要进行 server 的配置。
+- 请在 `/resource/server-config.yml` 中配置 `sourceEnable`为`true` 以开启 source 功能。
+- 请在 `/resource/source-config.yml`中配置 source connector, 在此仅说明 
`connectorConfig` 下的配置:
+  - `connectorName`, connector的名称
+  - (必需) `path`, 接口的路径
+  - (必需) `port`, 接口的端口
+  - `idleTimeout`, 空闲TCP连接超时时间,单位为秒。超过 `idleTimeout` 
秒没有进行数据接收或发送的连接将会发生超时并被关闭。默认为0, 不会发生超时。
+
+### 1.2 启动
+
+1. 启动 eventmesh-runtime
+2. 启动 eventmesh-connector-http
+
+完成后,HTTP source connector 会作为一个 HTTP 服务器对外提供服务。
+
+### 1.3 发送消息
+你可以通过HTTP向 source connector 发送消息。
+```yaml
+connectorConfig:
+    connectorName: httpSource
+    path: /test
+    port: 3755
+    idleTimeout: 5
+```
+上述的例子在`source-config.yml`中配置了一个URL`http://localhost:3755/test`.
+
+你可以按照[cloudevent-spec](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/bindings/http-protocol-binding.md)中的规定,以`binary`模式或者`structured`模式发送消息。
+
+这里是两个例子:
+
+以`binary`模式发送消息。
+```shell
+curl --location --request POST 'http://localhost:3755/test' \
+--header 'ce-id: 1' \
+--header 'ce-specversion: 1.0' \
+--header 'ce-type: com.example.someevent' \
+--header 'ce-source: /mycontext' \
+--header 'ce-subject: test_topic' \
+--header 'Content-Type: text/plain' \
+--data-raw 'testdata'
+```
+
+以`structured`模式发送消息。
+```shell
+curl --location --request POST 'http://localhost:3755/test' \
+--header 'Content-Type: application/cloudevents+json' \
+--data-raw '{
+    "id": "1",
+    "specversion": "1.0",
+    "type": "com.example.someevent",
+    "source": "/mycontext",
+    "subject":"test_topic",
+    "datacontenttype":"text/plain",
+    "data": "testdata"
+}'
+```
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to