-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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(lambda): event-source maxBatchingWindow property #4260
Conversation
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
* The maximum amount of time to gather records before invoking the function. | ||
* Maximum of Duration.minutes(5) | ||
* | ||
* @default Duration.seconds(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.
I couldn't find documentation on the default, but I'm assuming that since this is a new feature, the previous behavior is the default.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
* | ||
* @default Duration.seconds(0) | ||
*/ | ||
readonly maximumBatchingWindow?: Duration; |
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.
Use terser form max
instead of maximum
everywhere.
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@@ -4,3 +4,4 @@ export * from './sqs'; | |||
export * from './s3'; | |||
export * from './sns'; | |||
export * from './api'; | |||
export * from './stream'; |
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.
This is an internal refactoring to reduce code duplication. I don't see value in exporting these to consumers (i.e., public API). In fact, it might limit our flexibility to change this in the future.
import lambda = require('@aws-cdk/aws-lambda'); | ||
import {Duration} from "@aws-cdk/core"; | ||
|
||
export interface StreamingEventSourceProps { |
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.
Keep the name consistent - use StreamEventSourceProps
.
export abstract class StreamEventSource implements lambda.IEventSource { | ||
protected constructor(protected readonly props: StreamingEventSourceProps, protected readonly maxBatchSize: number) { | ||
if (this.props.batchSize !== undefined && (this.props.batchSize < 1 || this.props.batchSize > maxBatchSize)) { | ||
throw new Error(`Maximum batch size must be between 1 and ${maxBatchSize} inclusive (given ${this.props.batchSize})`); |
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.
This feels somewhat over-delegated. Instead of passing maxBatchSize down here, throw this error in each of the subclasses.
throw new Error('Cannot bind StreamEventSource, use DynamoEventSource or KinesisEventSource'); | ||
} | ||
|
||
protected getEventSourceMappingOptions(eventSourceArn: string): lambda.EventSourceMappingOptions { |
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.
Same here about over-delegation. Don't pass the eventSourceArn
here. Instead insert it into the struct, returned by this method, at the calling point in the subclasses.
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.
This would break the requirement of the EventSourceMappingOptions
return type, which I'd like to keep. I could change it to Omit<EventSourceMappingOptions, 'eventSourceArn'>
, I'll see if JSII is alright with 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.
I see, good point.
How about renaming the method signature to enrichMappingOptions(options: lambda.EventSourceMappingOptions)
which would add the stream-related properties and return it back?
@@ -0,0 +1,52 @@ | |||
import lambda = require('@aws-cdk/aws-lambda'); | |||
import {Duration} from "@aws-cdk/core"; |
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.
Switch to single quotes.
@@ -1,44 +1,26 @@ | |||
import dynamodb = require('@aws-cdk/aws-dynamodb'); | |||
import lambda = require('@aws-cdk/aws-lambda'); | |||
import {StreamEventSource, StreamingEventSourceProps} from "./stream"; |
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.
Switch to use single quotes
Pull request has been modified.
The PR should be good to go. I was going to create a test suite for
EDIT: Never mind, I just remembered that TypeScript had abstract methods too. All good! |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request is now being automatically merged. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Implements the new
maxBatchingWindow
propertyKinesisEventSource
andDynamoEventSource
into commonStreamEventSource
Fixes #4257
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license