feat: implement payload-level filtering with CEL expressions #2064
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.
Implements #2058 - Add optional filter field to endpoints that evaluates CEL expressions against message payload for content-based routing.
Motivation
Currently, webhook endpoints receive all messages for their configured event types without any content-based filtering. This can lead to unnecessary webhook calls when endpoints only need to process messages that meet specific criteria based on payload content. For example, a DeFi application might only want to receive webhook notifications for transactions above a certain amount, or an NFT marketplace might only want notifications for specific collections.
The lack of payload-based filtering means:
Solution
This PR adds CEL (Common Expression Language) filtering support to webhook endpoints, allowing content-based routing of messages before dispatch.
Key Changes:
Database Schema: Added optional
filter
field to theendpoint
table to store CEL expressionsAPI Updates:
filter
field toEndpointIn
,EndpointUpdate
, andEndpointPatch
structsEndpointOut
to include the filter fieldCore Filtering Logic:
cel-parser
cratePerformance & Monitoring:
CelExecutionMetrics
to track execution time and complexityValidation & Safety:
Usage Example:
Test Coverage:
This solution enables more efficient webhook routing by filtering messages at the payload level, reducing unnecessary webhook calls and allowing for more sophisticated message routing based on content.