generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 181
Closed as not planned
Labels
feature-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 UtilityrejectedThis is something we will not be working on. At least, not in the measurable futureThis is something we will not be working on. At least, not in the measurable future
Description
Use Case
Users who write their Lambda functions as classes should be able to make their function handler idempotent via decorator.
Solution/User Experience
import { LambdaInterface } from '@aws-lambda-powertools/commons';
import {
idempotentHandler,
DynamoDBPersistenceLayer,
IdempotencyConfig,
} from '@aws-lambda-powertools/idempotency';
const config = new IdempotencyConfig({...});
const ddbPersistenceLayer = new DynamoDBPersistenceLayer({...});
class Lambda implements LambdaInterface {
// Decorate your handler class method
@idempotentHandler({
persistenceStore: ddbPersistenceLayer,
config
})
public async handler(_event: unknown, _context: unknown): Promise<void> {
/* ...Function logic here... */
}
}
export const handlerClass = new Lambda();
export const handler = handlerClass.handler.bind(handlerClass);The idempotentHandler decorator should be able to decorate an handler method of a LambdaInterface class, both async and sync. The decorator should accept an object with mandatory persistenceStore and an optional config one. The former should be an instance of any class that extends BasePersistenceLayer, while the latter should be an instance of the class IdempotencyConfig.
Following the Powertools for Python implementation, the decorator should:
- return early if the
POWERTOOLS_IDEMPOTENCY_DISABLEDenv variable has a truthy value (usingEnvironmentVariableService) - use the provided config object or instantiate a new one if none is passed
- register the Lambda context into the config object (used to manage timeouts)
- instantiate an
IdempotencyHandler - call & return the
IdempotencyHandler.handle()method
This last step will ensure that the IdempotencyHandler will perform all the actions needed to make the function idempotent.
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
feature-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 UtilityrejectedThis is something we will not be working on. At least, not in the measurable futureThis is something we will not be working on. At least, not in the measurable future
Type
Projects
Status
Closed