-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add support for maximumEventAge and maximumRetryAttempts directly on function instead of destinations
#7987
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
Adds support for defining maximumEventAge and maximumRetryAttempts directly on function level Adds deprecation of setting the above parameters on destinations
Codecov Report
@@ Coverage Diff @@
## master #7987 +/- ##
==========================================
- Coverage 88.13% 88.13% -0.01%
==========================================
Files 242 244 +2
Lines 9146 9186 +40
==========================================
+ Hits 8061 8096 +35
- Misses 1085 1090 +5
Continue to review full report at Codecov.
|
medikoo
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.
@pgrzesik thank you, looks very good! I've proposed some suggestions (nothing major)
docs/deprecations.md
Outdated
| <a name="AWS_FUNCTION_DESTINATIONS_MAXIMUM_EVENT_AGE"><div> </div></a> | ||
|
|
||
| ## AWS Lambda Function Destinations `maximumEventAge` | ||
|
|
||
| Please use `maximumEventAge` instead of `destinations.maximumEventAge`. Support for `destinations.maximumEventAge` will be removed with v2.0.0 | ||
|
|
||
| <a name="AWS_FUNCTION_DESTINATIONS_MAXIMUM_RETRY_ATTEMPTS"><div> </div></a> | ||
|
|
||
| ## AWS Lambda Function Destinations `maximumRetryAttempts` | ||
|
|
||
| Please use `maximumRetryAttempts` instead of `destinations.maximumRetryAttempts`. Support for `destinations.maximumRetryAttempts` will be removed with v2.0.0 | ||
|
|
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 simplicity let's use one deprecation, we can word it as:
maximumEventAge and maximumEventAge should be defined directly at function level. Support for those settings on destinations level, will be removed with v2.0.0
And code could probably be AWS_FUNCTION_DESTINATIONS_ASYNC_CONFIG
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.
Great idea 💯
| onFailure: arn:aws:sns:us-east-1:xxxx:some-topic-name | ||
| ``` | ||
|
|
||
| ## Maximum Event Age and Maximum Retry Attempts for Asynchronous Invocations |
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.
Let's maybe group the async config sections as follows:
## Asynchronous invocation
When intention is to invoke function asynchronously you may want to configure following additional settings
### Destinations
[destination targets](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-async-destinations) can be the other...
...
### Maximum Event Age and Maximum Retry Attempts
`maximumEventAge` accepts values between 60
...| const destinationConfig = {}; | ||
|
|
||
| if (destinations) { | ||
| if (destinations.maximumRetryAttempts !== undefined) { |
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.
Let's write it as: if (destinations.maximumRetryAttempts != null) (naturally we should discard both null and undefined
| maximumRetryAttemptsOnDestinations = destinations.maximumRetryAttempts; | ||
| } | ||
|
|
||
| if (destinations.maximumEventAge !== undefined) { |
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.
Here as all supported values are not falsy, check can be even simpler if (destinations.maximumEventAge)
| const maximumEventAge = maximumEventAgeOnFunction || maximumEventAgeOnDestinations; | ||
| // For maximumRetryAttempts we cannot rely on "||" as the value can be Falsy, 0 | ||
| const maximumRetryAttempts = | ||
| maximumRetryAttemptsOnFunction === undefined |
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.
Let's use == null comparision
| MaximumEventAgeInSeconds: maximumEventAge, | ||
| MaximumRetryAttempts: maximumRetryAttempts, |
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.
We should set those properties only if provided.
While above is harmless for undefined, if someone put null, it'll break CF deployment, while in such case we should ensure that no such property is set
|
@medikoo Thanks a lot for valuable and comprehensive code review with great tips - I pushed suggested changes - if there's anything else that you feel could be improved, I'm all ears (or eyes in this case) 💯 |
medikoo
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.
@pgrzesik thank you, looks great! I've proposed just few minor improvements to documentation, and we should be good to go
docs/deprecations.md
Outdated
|
|
||
| ## AWS Lambda Function Destinations `maximumEventAge` & `maximumRetryAttempts` | ||
|
|
||
| `maximumEventAge` and `maximumRetryAttempts` should be defined directly at function level. Support for those settings on destinations level, will be removed with v2.0.0 |
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.
Let's put destinations in backticks
|
|
||
| ### Maximum Event Age and Maximum Retry Attempts for Asynchronous Invocations | ||
|
|
||
| When intention is to invoke function asynchronously you may want to configure `maximumRetryAttempts` and/or `maximumEventAge` for it. |
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.
Sentence When intention is.. is duplicated among sections, therfore maybe organize this as follows:
## Asynchronous invocation
When intention is to invoke function asynchronously you may want to configure following additional settings
### Destinations
[destination targets](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-async-destinations) can be the other...
...
### Maximum Event Age and Maximum Retry Attempts
`maximumEventAge` accepts values between 60
...|
Thanks @medikoo for such a quick re-review 🙇 Sorry for not catching these the first time around, hopefully everything should be good to go now 🤞 |
medikoo
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.
Thank you @pgrzesik !
Adds support for defining
maximumEventAgeandmaximumRetryAttemptsdirectly on function level and deprecates the configuration on destinations.Closes: #7678
Open questions:
maximumEventAgeis between 60 seconds and 6 hours. Would it make sense to add such validation or it's unnecessary at this point?