eventmesh
eventmesh copied to clipboard
[ISSUE #5108] Abstracting and transforming EventMeshFunction, and implementing FunctionRuntime.
Fixes #5108
Motivation
To adapt to the V2 architecture, the EventMeshFunction section needs to be upgraded and transformed. This includes redefining EventMeshFunction, making adaptive modifications to the existing filter and transformer functionalities, and reserving a unified interface for potential new Function features in the future. Based on this, the code for FunctionRuntime will be completed.
Modifications
For the Function module:
- A new
eventmesh-functionmodule has been added, consolidating theapimodule and the originalfilterandtransformermodules for easier management. - The
EventMeshFunctioninterface has been defined with reference tojava.util.function.Function. The data in Eventmesh is processed through theapplymethod of the function. - The
AbstractEventMeshFunctionChainsubclass has been abstracted fromEventMeshFunction, defining additional methods for chain processing, such asaddFirst,addLast, etc. - The original
Transformerinterface now inherits from and implements theEventMeshFunctioninterface, including theapplymethod for compatibility.
For the FunctionRuntime module:
- Referring to
ConnectorRuntime, it implements connecting toadminServer, reporting heartbeat and current status to theadminServer, obtaining configuration information from theadminServer, and initializing theconnectorService. - A function processing chain is constructed based on the
FunctionConfigsin the configuration and is used to process data inConnectRecord.
Supplement:
Regarding FunctionConfigs in FunctionRuntime, the related configurations and functionalities are as follows:
-
Users can configure any number of
EventMeshFunctioninFunctionConfigsaccording to their needs:functionConfigs: # filter - functionType: filter condition: source: - prefix: "eventmesh." # transformer - functionType: transformer transformerType: template valueMap: data-name: "$.data.name" data-num: "$.data.num" event-type: "$.type" template: "{\"type\":\"${event-type}\",\"name\":\"${data-name}\",\"no\":${data-num}}" # filter - functionType: filter condition: type: - suffix: "put" # transformer - functionType: transformer transformerType: constant content: "{\"name\":\"jack\",\"no\":123}"In the above
EventMeshFunction, besides specifying thefunctionType, other fields are the same as those required by the originalFunction. For example, thefilterrequiresconditioninformation, which only needs to be added in the YAML file format. -
The
EventMeshFunctioninFunctionConfigswill be built into a function processing chain in sequence:input -> filter -> transformer -> filter -> transformer -> outputThe data entering the
FunctionRuntimewill flow along the route above. If the data is filtered, the processing will exit directly.
Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
- If a feature is not applicable for documentation, explain why?
- If a feature is not documented yet in this PR, please create a followup issue for adding the documentation