-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(type-safe-api): enable snapstart for java handlers by default an…
…d optimise java interceptors Java handlers now have snapstart enabled by default to improve cold start times. Ensure logger, metrics and tracer perform as much initialisation as possible during the init phase which can therefore be saved from snapstart invocations. Fixes #572
- Loading branch information
Showing
15 changed files
with
179 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
export * from "./snap-start-java-function"; |
30 changes: 30 additions & 0 deletions
30
packages/type-safe-api/src/construct/functions/snap-start-java-function.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
import { CfnFunction, Function, FunctionProps } from "aws-cdk-lib/aws-lambda"; | ||
import { Construct } from "constructs"; | ||
|
||
/** | ||
* Options for the SnapStartFunction construct | ||
*/ | ||
export interface SnapStartFunctionProps extends FunctionProps { | ||
/** | ||
* When true, disable snap start | ||
* @default false | ||
*/ | ||
readonly disableSnapStart?: boolean; | ||
} | ||
|
||
/** | ||
* A lambda function which enables SnapStart on published versions by default | ||
*/ | ||
export class SnapStartFunction extends Function { | ||
constructor(scope: Construct, id: string, props: SnapStartFunctionProps) { | ||
super(scope, id, props); | ||
|
||
if (!props.disableSnapStart) { | ||
(this.node.defaultChild as CfnFunction).addPropertyOverride("SnapStart", { | ||
ApplyOn: "PublishedVersions", | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 16 additions & 4 deletions
20
.../type-safe-api/test/scripts/generators/__snapshots__/java-cdk-infrastructure.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
14 changes: 12 additions & 2 deletions
14
...ges/type-safe-api/test/scripts/generators/__snapshots__/java-lambda-handlers.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.