-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(events): complex event pattern matching with the Match class
#21310
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
Conversation
rix0rrr
left a comment
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.
Nice! I love this! Just need to find a different way to encode the matchers... via tokens maybe?
| * @default - No filtering on version | ||
| */ | ||
| readonly version?: string[]; | ||
| readonly version?: string[] | IMatcher; |
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.
Avoid using union types in L2 libraries. Even though they work fine in TypeScript, they do not behave well in many of the other languages we target (See Design Guidelines, API Design, Props, Unions).
| /** | ||
| * A collection of matchers for constructing event patterns | ||
| */ | ||
| export class Matchers { |
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 think I'd prefer Match as a class name? It'll look nicer in code? As in, Match.anythingBut(...) ?
|
@otaviomacedo Is this missing a Matcher for an AND condition? Or is that something the service doesn't support? |
There is no general way to represent and AND condition. But there are two special cases:
|
|
|
||
| public readonly creationStack: string[]; | ||
|
|
||
| constructor(private readonly matchers: any[], |
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.
For current safety, can we make this a private constructor? I don't think I want people calling new Match() directly...
Match class
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
1 similar comment
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…ws#21310) The current API restricts event pattern matchers to arrays of strings, which do not cover all the functionality available for EventBridge patterns. Add a new matcher API that gets translated to the low-level JSON pattern matchers, to be consumed by EventBridge. This high-level API also adds: * **Better ergonomics**: users don’t have to remember where to use curly or square brackets; 'OR' and 'AND' conditions (where applicable) are clearly indicated. * **Aliases/syntax sugar**: `ipAddressRange()`, `anythingButPrefix()` and `interval()` hide some of the lower level complexity. * **Validation**: you can’t pass an invalid IP address range, or an interval with lower and upper bounds swapped, or empty lists of conditions. Resolves aws#20486, resolves aws#13330. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…ws#21310) The current API restricts event pattern matchers to arrays of strings, which do not cover all the functionality available for EventBridge patterns. Add a new matcher API that gets translated to the low-level JSON pattern matchers, to be consumed by EventBridge. This high-level API also adds: * **Better ergonomics**: users don’t have to remember where to use curly or square brackets; 'OR' and 'AND' conditions (where applicable) are clearly indicated. * **Aliases/syntax sugar**: `ipAddressRange()`, `anythingButPrefix()` and `interval()` hide some of the lower level complexity. * **Validation**: you can’t pass an invalid IP address range, or an interval with lower and upper bounds swapped, or empty lists of conditions. Resolves aws#20486, resolves aws#13330. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
The current API restricts event pattern matchers to arrays of strings, which do not cover all the functionality available for EventBridge patterns.
Add a new matcher API that gets translated to the low-level JSON pattern matchers, to be consumed by EventBridge. This high-level API also adds:
ipAddressRange(),anythingButPrefix()andinterval()hide some of the lower level complexity.Resolves #20486, resolves #13330.
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integto deploy the infrastructure and generate the snapshot (i.e.yarn integwithout--dry-run)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license