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-function
module has been added, consolidating theapi
module and the originalfilter
andtransformer
modules for easier management. - The
EventMeshFunction
interface has been defined with reference tojava.util.function.Function
. The data in Eventmesh is processed through theapply
method of the function. - The
AbstractEventMeshFunctionChain
subclass has been abstracted fromEventMeshFunction
, defining additional methods for chain processing, such asaddFirst
,addLast
, etc. - The original
Transformer
interface now inherits from and implements theEventMeshFunction
interface, including theapply
method 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
FunctionConfigs
in 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
EventMeshFunction
inFunctionConfigs
according 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, thefilter
requirescondition
information, which only needs to be added in the YAML file format. -
The
EventMeshFunction
inFunctionConfigs
will be built into a function processing chain in sequence:input -> filter -> transformer -> filter -> transformer -> output
The data entering the
FunctionRuntime
will 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