[ISSUE #4787]integration connector #4790
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4787
########
UnMergeable!!! its demo ,不能合并这只是用于讨论
########
Motivation
Integrate connector with minimal modification
Very simple integration using connecter
Modifications
Integrating 'connecter' means that 'connecter' has to have another running mode, and integrating into 'runtime' has some problems to solve
集成
connecter
,意味着connecter
要有另一种运行模式,集成到runtime
中有一些问题需要解决The first problem that needs to be solved is that the main method is not called, but
connecter
is a plug-in module, and it is troublesome to hard-code main once for each plug-in. So the method I think of is that all theconnecter
module's startup class inherits aEmbeddableConnector
interface, and uses theEventmesh-SPI
to load, so that the changes are broughtEmbeddableConnector
All startup classes in
Connector
(in this case,FileConnectServer
)All files referred to by
SPI
inConnector
首先需要解决的问题就是
main
方法没有被调用,但是connecter
是插件化的模块,为每一个插件都硬编码一次main
这样很麻烦,所以我想到的方法是所有connecter
模块的启动类都继承一个EmbeddableConnector
接口,使用Eventmesh
的SPI
进行加载,这样带来的修改就有EmbeddableConnector
所有
Connector
中的启动类(这个例子中的启动类是FileConnectServer
)所有
Connector
中SPI
涉及的文件Second, the original interaction between
connector
andruntime
usestcp protocol,
and the purpose of integration is to reduce serialization and communication consumption. Therefore, interaction needs to be realized in other ways. The method I think is to use the form of service. connector itself only has two roles,sink
andsource
, which are publish and subscribe in terms of function, so this service needs to use publish and subscribe functions. Meanwhile, in order to preserve the original structure and design to the greatest extent, the connector uses atcp adapter
(the adapter does not implement network communication in the middle). Instead, the service is called.) So the design changes areIInnerPubSubService Indicates the interface of the service
InnerPubSubService implementation
IntegrationCloudEventTCPClientAdapter TCP adapter
Application must have a static variable holding the service
The SinkWorker passes the service to the tcp adapter
SourceWorker transfers the service tcp adapter
其次需要解决的就是原有
connector
和runtime
之间的交互使用的是tcp协议
而集成的目的就是减少序列化和通信消耗,所以需要通过其他方式对交互进行实现,我想到的方法是使用服务的形式,connector
本身其实只有两种角色,sink
和source
,从功能来说就是发布和订阅,那么这个服务就需要用发布和订阅的功能即可,同时为了最大程度保留原有结构和设计,使用tcp适配器(适配器中间不在实现网络通信,而是对服务进行调用)所以设计的修改有IInnerPubSubService 服务的接口
InnerPubSubService 服务的实现
IntegrationCloudEventTCPClientAdapter tcp适配器
Application 要有静态变量持有服务
SinkWorker 传递服务给tcp适配器
SourceWorker 传递服务tcp适配器
Unfinished changes:
The implementation of InnerPubSubService
未完成的修改:
InnerPubSubService
的具体实现达成的效果:
只要
gradle
引用了对应的connector
插件就会自动处理 内嵌connector
相关逻辑Results achieved:
The built-in
connector
logic is automatically handled whenevergradle
references the correspondingconnector
plug-in