-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(sns): add delivery policy to sns subscriptions #30830
base: main
Are you sure you want to change the base?
feat(sns): add delivery policy to sns subscriptions #30830
Conversation
* Algorithms which can be used by SNS to calculate the delays associated with all of the retry attempts between the first and last retries in the backoff phase. | ||
*/ | ||
export enum BackoffFunction { | ||
/** Arithmetic. |
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.
Not the best doc I've ever written 😅 , the best indicator of to what these each of these do that I found was an image at the very bottom of the doc page here: https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html - suggestions welcome.
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 couldn't come up with a good description either, but I thought it would be good to at least add a link to this diagram, which shows the differences in the behavior of each backoff function.
However, it seems that this diagram doesn't exist in English😓
In Japanese: https://docs.aws.amazon.com/de_de/sns/latest/dg/sns-message-delivery-retries.html#creating-delivery-policy
In English: https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html
I would appreciate it if you could consult with the maintainer again.
/** The minimum delay for a retry (in seconds). Must be at least 1 and not exceed `maxDelayTarget`. | ||
* @default 20 | ||
*/ | ||
readonly minDelayTarget: number; |
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.
Only, this and the next two appear to be mandatory if healthyRetryPolicy
is specified, thought I can't find any specific doc for this.
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.
Would it be correct to assume that if these are not set, it will result in an error during deployment? If so, I am curious when the default values would be set.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Hi This PR has been pending for community review for a while. Please consider posting it on the #contributing channel in cdk.dev. Community members will be on the lookout there as well for possible reviews. Check How to get your P2 PR community reviewed for more details. |
Thanks, I've posted on the channel. |
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 for creating such a wonderful PR! I’ve quickly reviewed it!
/** Linear. | ||
*/ |
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.
/** Linear. | |
*/ | |
/** | |
* Linear | |
*/ |
/** Linear. | ||
*/ |
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.
/** Linear. | |
*/ | |
/** | |
* Geometric | |
*/ |
/** Geometric. | ||
*/ |
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.
/** Geometric. | |
*/ | |
/** | |
* Exponential | |
*/ |
* Algorithms which can be used by SNS to calculate the delays associated with all of the retry attempts between the first and last retries in the backoff phase. | ||
*/ | ||
export enum BackoffFunction { | ||
/** Arithmetic. |
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 couldn't come up with a good description either, but I thought it would be good to at least add a link to this diagram, which shows the differences in the behavior of each backoff function.
However, it seems that this diagram doesn't exist in English😓
In Japanese: https://docs.aws.amazon.com/de_de/sns/latest/dg/sns-message-delivery-retries.html#creating-delivery-policy
In English: https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html
I would appreciate it if you could consult with the maintainer again.
/** The maximum number of deliveries per second, per subscription. | ||
* @default - no throttling | ||
*/ |
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.
Could you also insert line breaks in the same way for the other JSDOC comments?
/** The maximum number of deliveries per second, per subscription. | |
* @default - no throttling | |
*/ | |
/** | |
* The maximum number of deliveries per second, per subscription. | |
* | |
* @default - no throttling | |
*/ |
/** The minimum delay for a retry (in seconds). Must be at least 1 and not exceed `maxDelayTarget`. | ||
* @default 20 | ||
*/ | ||
readonly minDelayTarget: number; |
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.
Would it be correct to assume that if these are not set, it will result in an error during deployment? If so, I am curious when the default values would be set.
if (healthyRetryPolicy.minDelayTarget < 1 || healthyRetryPolicy.minDelayTarget > delayTargetLimit) { | ||
throw new Error(`minDelayTarget must be between 1 and ${delayTargetLimit} inclusive`); | ||
} |
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.
In order to support Duration, please make the following modifications.
if (healthyRetryPolicy.minDelayTarget < 1 || healthyRetryPolicy.minDelayTarget > delayTargetLimit) { | |
throw new Error(`minDelayTarget must be between 1 and ${delayTargetLimit} inclusive`); | |
} | |
const minDelayTarget = healthyRetryPolicy.minDelayTarget | |
const maxDelayTarget = healthyRetryPolicy.maxDelayTarget | |
if (minDelayTarget.toMilliseconds() < Duration.seconds(1).toMilliseconds()) { | |
throw new Error(`minDelayTarget must be at least 1 second, got ${minDelayTarget.toMilliseconds()}ms.`); | |
} | |
if (maxDelayTarget.toMilliseconds() < Duration.seconds(1).toMilliseconds()) { | |
throw new Error(`maxDelayTarget must be at least 1 second, got ${maxDelayTarget.toMilliseconds()}ms.`); | |
} | |
if (minDelayTarget.toSeconds() < 1 || minDelayTarget.toSeconds() > delayTargetLimit) { | |
throw new Error(`minDelayTarget must be between 1 and ${delayTargetLimit} seconds inclusive`); | |
} |
if (healthyRetryPolicy.maxDelayTarget < 1 || healthyRetryPolicy.maxDelayTarget > delayTargetLimit) { | ||
throw new Error(`maxDelayTarget must be between 1 and ${delayTargetLimit} inclusive`); | ||
} | ||
if (healthyRetryPolicy.minDelayTarget > healthyRetryPolicy.maxDelayTarget) { | ||
throw new Error('minDelayTarget must not exceed maxDelayTarget'); | ||
} |
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.
Could you also adjust these if statements to support Duration?
throw new Error('minDelayTarget must not exceed maxDelayTarget'); | ||
} | ||
const numRetriesLimit = 100; | ||
if (healthyRetryPolicy.numRetries < 0 || healthyRetryPolicy.numRetries > numRetriesLimit) { |
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.
Is it necessary to validate that numRetries
is an Integer?
@@ -136,6 +144,43 @@ export class Subscription extends Resource { | |||
throw new Error('Subscription role arn is required field for subscriptions with a firehose protocol.'); | |||
} | |||
|
|||
if (props.deliveryPolicy) { |
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.
How about performing these validations inside the renderDeliveryPolicy()
?
Issue # (if applicable)
Closes #17576.
Reason for this change
To allow setting of delivery policy for appropriate sns subscriptions.
Description of changes
Subscriptions can now take a new parameter
deliveryPolicy
which consists of ahealthyRetryPolicy
, athrottlePolicy
, and arequestPolicy
(each having the same parameters described here: https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html#creating-delivery-policy).Description of how you validated changes
New integration test along with unit tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license