UNPKG

@aws-lambda-powertools/idempotency

Version:

The idempotency package for the Powertools for AWS Lambda (TypeScript) library. It provides options to make your Lambda functions idempotent and safe to retry.

32 lines (31 loc) 1.02 kB
/** * Number of times to retry a request in case of `IdempotencyInconsistentStateError` * * Used in `IdempotencyHandler` and `makeHandlerIdempotent` * * @internal */ const MAX_RETRIES = 2; /** * Idempotency record status. * * A record is created when a request is received. The status is set to `INPROGRESS` and the request is processed. * After the request is processed, the status is set to `COMPLETED`. If the request is not processed within the * `inProgressExpiryTimestamp`, the status is set to `EXPIRED`. */ const IdempotencyRecordStatus = { INPROGRESS: 'INPROGRESS', COMPLETED: 'COMPLETED', EXPIRED: 'EXPIRED', }; /** * Base persistence attribute key names for persistence layers */ const PERSISTENCE_ATTRIBUTE_KEY_MAPPINGS = { statusAttr: 'status', expiryAttr: 'expiration', inProgressExpiryAttr: 'in_progress_expiration', dataAttr: 'data', validationKeyAttr: 'validation', }; export { IdempotencyRecordStatus, MAX_RETRIES, PERSISTENCE_ATTRIBUTE_KEY_MAPPINGS, };