-
Notifications
You must be signed in to change notification settings - Fork 4k
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
chore(lambda-event-sources): refactoring the filters type #22096
Conversation
Pull request has been modified.
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). |
Pull request has been modified.
I had to update the branch last time because somehow PR Linter broke, you can check if it's good |
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.
Hi @marciocadev! I know this PR was preivously approved but I have some concerns about the behavior of the property you are deprecating. We need to make sure that filters
continues to work even though its deprecated.
Your comments are perfect |
Pull request has been modified.
@marciocadev, refactoring is tough when we have a stable api! I think what we had before with deprecating |
Pull request has been modified.
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.
@marciocadev this is still not okay. While the API is no longer breaking, the behavior is. We still need the following to work as usual:
filters: [
FilterCriteria.filter({
numericEquals: FilterRule.isEqual(1),
}),
]
In this case, the resulting object includes the pattern
key. We then try to send this into FilterCriteria.addFilter(filter).toPattern()
, which will add another pattern
key to the resulting object. This duplication is unexpected, and wrong.
The only path forward I see is a deprecation of the filters
property. We cannot successfully support two different ways of providing an object to filters
in a maintainable way. I expressly don't want to have any logic that checks to see if pattern
exists before adding it (to avoid the duplication you've got going). We must deprecate filters
and add a new property with the type you want.
Please note that I would like you to keep at least 1 test that tests the legacy behavior to make sure that it has not changed.
@kaizencc I don't undestand, if I deprecate The initial problem is that the I don't know if I need to deprecate |
Hi @marciocadev:
That isn't necessarily true. new EventSourceMapping(stack, 'test', {
target: fn,
eventSourceArn: eventSourceArn,
kafkaTopic: topicNameParam.valueAsString,
filters: [
FilterCriteria.filter({
numericEquals: FilterRule.isEqual(1),
}),
],
}); And it's weird because the user doesn't know to supply a new EventSourceMapping(stack, 'test', {
target: fn,
eventSourceArn: eventSourceArn,
kafkaTopic: topicNameParam.valueAsString,
filters: [
pattern: {
numericEquals: FilterRule.isEqual(1),
}),
],
}); Which is perfectly fine and should work. The alternative you've suggested doesn't really help. In fact, I think it will confuse users because the only difference is whether you supply new EventSourceMapping(stack, 'test', {
target: fn,
eventSourceArn: eventSourceArn,
kafkaTopic: topicNameParam.valueAsString,
filters: [
{
numericEquals: FilterRule.isEqual(1),
},
],
}); Am I missing something here? What was the original motivation behind having a |
Hi @kaizencc My motivation was to make it clearer that the ideal was to use I think it's complicated to use it as it is today But if you think the way it is today is enough, I can close this PR |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
As it stands, I don't think |
Description
Changing
filters
type fromArray<{[key: string]: any}>
toArray<FilterCriteria>
.This way it will be easier for the developer to understand what type of parameter should be passed
All Submissions:
Adding new Unconventional Dependencies:
New Features
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