Skip to content

Conversation

@pgrzesik
Copy link
Contributor

Adds support for defining maximumEventAge and maximumRetryAttempts directly on function level and deprecates the configuration on destinations.

Closes: #7678

Open questions:

  • I wasn't sure about the approach to deprecation - I went with two separate deprecations for each parameter, but maybe it would make more sense to combine it into one instead? I would love to get your opinion on this one
  • I followed the previous approach where I didn't notice any validation of the provided input e.g. if maximumEventAge is between 60 seconds and 6 hours. Would it make sense to add such validation or it's unnecessary at this point?

pgrzesik added 3 commits July 25, 2020 13:17
Adds support for defining maximumEventAge and maximumRetryAttempts
directly on function level

Adds deprecation of setting the above parameters on destinations
@codecov-commenter
Copy link

codecov-commenter commented Jul 25, 2020

Codecov Report

Merging #7987 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
lib/plugins/aws/package/compile/functions/index.js 97.21% <100.00%> (+0.14%) ⬆️
lib/plugins/aws/provider/awsProvider.js 92.74% <0.00%> (-0.09%) ⬇️
lib/plugins/create/create.js 90.69% <0.00%> (ø)
lib/utils/awsSdkPatch.js 50.00% <0.00%> (ø)
lib/utils/getEnsureArtifact.js 89.47% <0.00%> (ø)
lib/plugins/aws/invokeLocal/index.js 69.56% <0.00%> (+0.10%) ⬆️
lib/plugins/aws/customResources/generateZip.js 100.00% <0.00%> (+10.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6216f35...9cd2e10. Read the comment docs.

Copy link
Contributor

@medikoo medikoo left a 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)

Comment on lines 9 to 20
<a name="AWS_FUNCTION_DESTINATIONS_MAXIMUM_EVENT_AGE"><div>&nbsp;</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>&nbsp;</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

Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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
Copy link
Contributor

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

Comment on lines 617 to 618
MaximumEventAgeInSeconds: maximumEventAge,
MaximumRetryAttempts: maximumRetryAttempts,
Copy link
Contributor

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

@pgrzesik
Copy link
Contributor Author

@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) 💯

Copy link
Contributor

@medikoo medikoo left a 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


## 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
Copy link
Contributor

@medikoo medikoo Jul 29, 2020

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.
Copy link
Contributor

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
...

@pgrzesik
Copy link
Contributor Author

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 🤞

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pgrzesik !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for maximum event age

3 participants