-
Notifications
You must be signed in to change notification settings - Fork 161
Closed
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityidempotencyThis item relates to the Idempotency UtilityThis item relates to the Idempotency Utility
Milestone
Description
Use case
To help dealing with timeouts, users should be hable to bind the Lambda function's context with the Idempotency utility. The utility will then use the information regarding time remaining before timeout to handle idempotency record expiration internally.
Solution/User Experience
In some cases, like when making a custom function (aka not the handler) idempotent, customers might want to instantiate the config item within the scope, in this case they can pass the context directly to the constructor:
import { Context } from 'aws-lambda';
import { IdempotencyConfig } from '@aws-lambda-powertools/idempotency';
export const handler = (_event: unknown, context: Context) => {
const config = new IdempotencyConfig({
lambdaContext: context,
});
};
In other (most) cases, customers will instantiate the config object outside of the handler, and then register the context by calling a method:
import { Context } from 'aws-lambda';
import { IdempotencyConfig } from '@aws-lambda-powertools/idempotency';
const config = new IdempotencyConfig({});
export const handler = (_event: unknown, context: Context) => {
config.registerLambdaContext(context);
};
Alternative solutions
No response
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Python, Java
Metadata
Metadata
Assignees
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityidempotencyThis item relates to the Idempotency UtilityThis item relates to the Idempotency Utility