Skip to content
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 #148] Add connectors documents #150

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions docs/design-document/03-connect/00-connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,50 @@

## Connector

A connector is a bridge that interacts with a specific external service or underlying data source (e.g., Databases) on behalf of user applications. A connector is either a Source or a Sink.
A connector is an image or instance that interacts with a specific external service or underlying data source (e.g., Databases) on behalf of user applications. A connector is either a Source or a Sink.

## Source

A source connector obtains data from an underlying data producer, and delivers it to targets after original data has been transformed into CloudEvents. It doesn't limit the way how a source retrieves data. (e.g., A source may pull data from a message queue or act as an HTTP server waiting for data sent to it).

CloudEvents is a specification for describing event data in common formats to provide interoperability across services, platforms and systems.

## Sink

A sink connector receives CloudEvents and does some specific business logics. (e.g., A MySQL Sink extracts useful data from CloudEvents and writes them to a MySQL database).

## CloudEvents

A specification for describing event data in common formats to provide interoperability across services, platforms and systems.

## Implements

Add a new connector by implementing the source/sink interface using [eventmesh-openconnect-java](https://github.com/apache/eventmesh/tree/master/eventmesh-openconnect/eventmesh-openconnect-java).

## Technical Solution

### Structure and process
![source-sink connector architecture](../../../static/images/design-document/connector-architecture.png)

### Design Detail
![eventmesh-connect-detail](../../../static/images/design-document/connector-design-detail.png)

### Describe

#### Worker

Worker is divided into Source Worker and Sink Worker, which are triggered by the `Application` class and implement the methods of the `ConnectorWorker` interface respectively, which include the worker's running life cycle, and the worker carries the running of the connector. Workers can be lightweight and independent through mirroring Running, the eventmesh-sdk-java module is integrated internally, and the cloudevents protocol is used to interact with eventmesh. Currently, the tcp client is used by default. In the future, support for dynamic configuration can be considered

#### Connector

Connectors are divided into Source Connector and Sink Connector. Connectors have their own configuration files and run independently. Workers perform reflective loading and configuration analysis to complete Connector initialization and subsequent operation. Source Connector implements the poll method, and Sink Connector implements The put method uniformly uses `ConnectorRecord` to carry data. Both Source Connector and Sink Connector can operate independently.

#### ConnectorRecord with CloudEvents

`ConnectorRecord` is a connector layer data protocol. When workers interact with eventmesh, a protocol adapter needs to be developed to convert `ConnectorRecord` to CloudEvents protocol.

#### Registry

The Registry module is responsible for storing the synchronization progress of synchronizing data of different Connector instances, ensuring high availability between multiple Connector images or instances.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part of the codes does this correspond to? Or is this a plan for the future of Connector?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pandaapo The offsets (consume progress) of connectors are stored in Meta (known as Registry like Nacos) by eventmesh-openconnect-offsetmgmt-plugin module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your answer.


## Connector Status

| Connector Name | Source | Sink |
Expand Down
39 changes: 39 additions & 0 deletions docs/design-document/03-connect/03-rabbitmq-connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# RabbitMQ

## RabbitMQSinkConnector: from eventmesh to rabbitmq.

1. launch your rabbitmq server and eventmesh-runtime.
2. enable sinkConnector and check `sink-config.yml`.
3. send a message to eventmesh with the topic defined in `pubSubConfig.subject`
```yaml
pubSubConfig:
# default port is 10000
meshAddress: your.eventmesh.server:10000
subject: TopicTest
idc: FT
env: PRD
group: rabbitmqSink
appId: 5031
userName: rabbitmqSinkUser
passWord: rabbitmqPassWord
connectorConfig:
connectorName: rabbitmqSink
host: your.rabbitmq.server
port: 5672
username: coyrqpyz
passwd: passwd
virtualHost: coyrqpyz
exchangeType: TOPIC
# build-in exchangeName or name a new one after you create it in rabbitmq server.
exchangeName: amq.topic
# rabbitmq server will create the routingKey and queueName automatically after you connect to it if they aren't exist before.
routingKey: eventmesh
queueName: eventmesh
autoAck: true
```

## RabbitMQSourceConnector: from rabbitmq to eventmesh.
1. launch your rabbitmq server and eventmesh-runtime.
2. enable sourceConnector and check `source-config.yml` (Basically the same as `sink-config.yml`)
3. start your `RabbitMQConnectorServer` and you will find the channel in rabbitmq server.
4. send a cloudevent message to the queue and then you will receive the message in eventmesh.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,49 @@

## 连接器类型

一个连接器就是一座桥梁,代表用户应用程序与特定的外部服务或底层数据源(例如数据库)进行交互。连接器的类型可以是源(Source)或汇(Sink)。
连接器是代表用户应用程序与特定外部服务或底层数据源(例如数据库)交互的镜像或实例。连接器的类型可以是源(Source)或汇(Sink)。

## 数据源(Source 端)

源连接器从底层数据生产者获取数据,并在原始数据被转换为 CloudEvents 后将其传递给目标。源连接器不限制源如何检索数据(例如,源可以从消息队列中获取数据,也可以充当等待接收数据的 HTTP 服务器)。

CloudEvents 是一种以通用格式描述事件数据的规范,以提供服务、平台和系统之间的互操作性。

## 数据汇(Sink 端)

汇连接器接收 CloudEvents 并执行特定的业务逻辑(例如,MySQL 的汇连接器从 CloudEvents 中提取有用的数据,并将其写入 MySQL 数据库)。

## CloudEvents

CloudEvents 是一种以通用格式描述事件数据的规范,以提供服务、平台和系统之间的互操作性。

## 实现连接器

使用 [eventmesh-openconnect-java](https://github.com/apache/eventmesh/tree/master/eventmesh-openconnect/eventmesh-openconnect-java) 实现 Source/Sink 接口即可添加新的连接器。

## 技术方案
### 结构与处理流程
![source-sink connector architecture](../../../../../../static/images/design-document/connector-architecture.png)

### 详细设计
![eventmesh-connect-detail](../../../../../../static/images/design-document/connector-design-detail.png)

### 描述

#### Worker

Worker分为Source Worker与Sink Worker,由`Application`类进行触发运行,分别实现了`ConnectorWorker`接口的方法,其中包含了worker的运行生命周期,worker承载了connector的运行。Worker可以通过镜像的方式轻量的独立运行,内部集成了eventmesh-sdk-java模块,采用cloudevents协议与eventmesh进行交互,目前默认采用tcp客户端,后续可以考虑支持动态可配

#### Connector

Connector分为Source Connector与Sink Connector,connector有各自的配置文件,以及独立运行的方式,通过worker进行反射加载与配置解析,完成Connector的初始化以及后续运行工作,其中Source Connector实现poll方法,Sink Connector实现put方法,统一使用`ConnectorRecord`承载数据。Source Connector与Sink Connector均可独立运行。

#### ConnectorRecord with CloudEvents

`ConnectorRecord`为connector层数据协议,当worker与eventmesh进行交互时需开发协议适配器进行`ConnectorRecord`到CloudEvents的协议转换。

#### Registry

`Registry`模块负责存储同步不同Connector实例的数据的同步进度,确保多个Connector镜像或实例之间的高可用。

## 连接器实现状态

| 连接器名称 | 源 | 汇 |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# RabbitMQ

## RabbitMQSinkConnector:从 eventmesh 到 rabbitmq。

1. 启动你的 rabbitmq 服务和 eventmesh-runtime。
2. 启用 sinkConnector 并检查 `sink-config.yml`。
3. 向 eventmesh 发送带有在 `pubSubConfig.subject` 中定义的主题消息。
```yaml
pubSubConfig:
# 默认端口 10000
meshAddress: your.eventmesh.server:10000
subject: TopicTest
idc: FT
env: PRD
group: rabbitmqSink
appId: 5031
userName: rabbitmqSinkUser
passWord: rabbitmqPassWord
connectorConfig:
connectorName: rabbitmqSink
host: your.rabbitmq.server
port: 5672
username: coyrqpyz
passwd: passwd
virtualHost: coyrqpyz
exchangeType: TOPIC
# 使用内置的 exchangeName 或在连接到 rabbitmq 服务后创建新的 exchangeName。
exchangeName: amq.topic
# 如果在连接之前不存在,rabbitmq 服务将自动创建 routingKey 和 queueName。
routingKey: eventmesh
queueName: eventmesh
autoAck: true
```

## RabbitMQSourceConnector:从 rabbitmq 到 eventmesh。

1. 启动你的 rabbitmq 服务器和 eventmesh-runtime。
2. 启用 sourceConnector 并检查 `source-config.yml`(与 sink-config.yml 基本相同)。
3. 启动你的 RabbitMQConnectorServer,你会在 rabbitmq 服务中找到该channel。
4. 向队列发送一个 cloudevent 消息,然后你将在 eventmesh 中接收到该消息。
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.