-
Notifications
You must be signed in to change notification settings - Fork 625
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
[WIP][ISSUE #4043]initial implementation of filter and transform #4365
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome to the Apache EventMesh community!!
This is your first PR in our project. We're very excited to have you onboard contributing. Your contributions are greatly appreciated!
Please make sure that the changes are covered by tests.
We will be here shortly.
Let us know if you need any help!
Want to get closer to the community?
WeChat Assistant | WeChat Public Account | Slack |
---|---|---|
![]() |
![]() |
Join Slack Chat |
Mailing Lists:
Name | Description | Subscribe | Unsubscribe | Archive |
---|---|---|---|---|
Users | User support and questions mailing list | Subscribe | Unsubscribe | Mail Archives |
Development | Development related discussions | Subscribe | Unsubscribe | Mail Archives |
Commits | All commits to repositories | Subscribe | Unsubscribe | Mail Archives |
Issues | Issues or PRs comments and reviews | Subscribe | Unsubscribe | Mail Archives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmupkin Please link this pr to related issue
First of all, I like your way of submitting PR: breaking down a task into multiple PRs, which avoids submitting a very large PR all at once. Your approach can greatly improve the quality of review and reduce the difficulty of review. 👍 Secondly, since your initial implementation has not been applied to the business of EventMesh yet, could you please add documentation to your code (including classes and methods) to help developers and reviewers understand their purpose and future roles in EventMesh? Also, please refer to https://eventmesh.apache.org/community/contribute/contribute/#code-style to check your code style. |
+ " \"f-count\": [{\"exists\": false}]\n" + " }\n" + " },\n" | ||
+ " \"prefix\": [{\"prefix\": \"aliyun-\"}],\n" | ||
+ " \"suffix\": [{\"suffix\": \"-eventbridge\"}]\n" + " }\n" + "}"; | ||
System.out.println(st); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have addressed the code style issues and removed some code. Can you please review it again?
@xwm1992 please review it. |
@pmupkin please link to the right issue. |
Okay, I've added some explanations and clarifications, and I've also re-linked the related issues. |
Codecov Report
@@ Coverage Diff @@
## master #4365 +/- ##
============================================
+ Coverage 15.47% 16.07% +0.60%
- Complexity 1452 1532 +80
============================================
Files 691 710 +19
Lines 28106 28445 +339
Branches 2626 2675 +49
============================================
+ Hits 4349 4573 +224
- Misses 23312 23391 +79
- Partials 445 481 +36
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
||
|
||
public String getPatternName() { | ||
return "123"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this return used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Initial Informal Implementation of Filter and Transform. Link to relevant issues: #825 . #4043 . #3263
1. Overview
Filter and transformer are components of EventMesh used for event filtering and event transformation. During the process of sending and receiving events in EventMesh, rules for event filtering and transformation can be configured to achieve the capability of filtering and transforming events.
Filter refers to the process of filtering events in event subscriptions using configured filtering rules, and then routing the filtered events to event destinations.
Transformer refers to the process of transforming the content of events by configuring types in event subscriptions, converting CloudEvents standard events into event types that event destinations can accept.
Both of these functionalities are implemented using Jackson and JsonPath.
Filter
Filter is an event filtering module. Its primary function is to match events generated by the event source with filtering rules. Only when a successful match occurs, the event will be routed to the event destination associated with the filtering rule. The filtering rule must have the same structure as the matched event.
Supported filtering conditions:
prefix
.anything-but
.suffix
.numeric
.exists
.Matching between different fields is performed using AND logic, while matching within the same field is performed using OR logic by default.
Processing Flow
The implementation of the filter primarily relies on patterns and conditions. The execution flow of the filter is illustrated in the diagram below:
![未命名文件 (11)](https://private-user-images.githubusercontent.com/18901988/269017094-422032eb-7fcf-4cfe-8eab-5468354c33a0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE1NTU1MjksIm5iZiI6MTcyMTU1NTIyOSwicGF0aCI6Ii8xODkwMTk4OC8yNjkwMTcwOTQtNDIyMDMyZWItN2ZjZi00Y2ZlLThlYWItNTQ2ODM1NGMzM2EwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIxVDA5NDcwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEzNWE5MDk1YzUwZDNlZjg3Y2FlOThkZTJkYzZjYzgxZDdkOWEwN2VlYjQ3ZDRkZmE1NTE2OTMwMTRjOTU0YzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jytoH6nxzhy7W5mDNpyVf4MvTphTdIUdfNjNvLsNFjo)
PatternBuilder: Responsible for parsing the condition content and generating patterns.
Pattern: Evaluates events based on filtering conditions and returns results.
ConditionBuilder: Constructs specific conditions based on different condition keywords.
Condition: Includes various matching conditions, each with its own matching implementation.
Transformer
The transformer is an event conversion module designed to transform CloudEvents standard events into types that the event target can process.
Transformer supports three types of transformations:
Direct Transfer: No event transformation is performed; the CloudEvents standard event is directly routed to the target.
Constant: Regardless of the event content, the event triggers the event target without sending the event content to the target.
Variable: Extract variable values from the CloudEvents standard event and route them to the event target according to the format defined in the template. Users can define custom templates and specify the list of variables to extract. The transformer will extract the variables from the event and route them to the event target according to the template's defined format.
As an example of template matching in the transformer, the implementation is as follows:
![未命名文件 (12)](https://private-user-images.githubusercontent.com/18901988/269018564-432b63ed-5ca2-4fcc-a31f-e2d2b10a2af4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE1NTU1MjksIm5iZiI6MTcyMTU1NTIyOSwicGF0aCI6Ii8xODkwMTk4OC8yNjkwMTg1NjQtNDMyYjYzZWQtNWNhMi00ZmNjLWEzMWYtZTJkMmIxMGEyYWY0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIxVDA5NDcwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI4ZDgxZGE3YjNhNDc5Y2NkMTdjOTA3YTBmMGUxOTU2ZjFlYzk0NDc5NTJiMDA3ZmM3NDQyOTk4ZDE2NDg0YjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9aFhMCh6ASI7-VIIpyZR7I4rI66mhFcpuZPu_kLVii0)