Skip to content
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

Feature request: Custom Config - Lambda context #1302

Closed
1 of 2 tasks
saragerion opened this issue Feb 17, 2023 · 1 comment · Fixed by #1376
Closed
1 of 2 tasks

Feature request: Custom Config - Lambda context #1302

saragerion opened this issue Feb 17, 2023 · 1 comment · Fixed by #1376
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility idempotency This item relates to the Idempotency Utility

Comments

@saragerion
Copy link
Contributor

saragerion commented Feb 17, 2023

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

@saragerion saragerion added triage This item has not been triaged by a maintainer, please wait feature-request This item refers to a feature request for an existing or new utility labels Feb 17, 2023
@saragerion saragerion added this to the Idempotency - Beta release milestone Feb 17, 2023
@saragerion saragerion added the idempotency This item relates to the Idempotency Utility label Feb 17, 2023
@dreamorosi dreamorosi added discussing The issue needs to be discussed, elaborated, or refined and removed triage This item has not been triaged by a maintainer, please wait labels Feb 17, 2023
@dreamorosi dreamorosi changed the title Feature request (idempotency): Custom Config - Lambda context Feature request: Custom Config - Lambda context Feb 17, 2023
@dreamorosi dreamorosi self-assigned this Mar 19, 2023
@dreamorosi dreamorosi added completed This item is complete and has been merged/shipped and removed discussing The issue needs to be discussed, elaborated, or refined labels Mar 19, 2023
@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation and removed completed This item is complete and has been merged/shipped labels Mar 20, 2023
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi added completed This item is complete and has been merged/shipped and removed confirmed The scope is clear, ready for implementation labels Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility idempotency This item relates to the Idempotency Utility
Projects
None yet
2 participants