Class BasePersistenceStore

java.lang.Object
software.amazon.lambda.powertools.idempotency.persistence.BasePersistenceStore
All Implemented Interfaces:
PersistenceStore

public abstract class BasePersistenceStore extends Object implements PersistenceStore
Persistence layer that will store the idempotency result. Base implementation. See
invalid reference
DynamoDBPersistenceStore
for an implementation (default one) Extends this class to use your own implementation (DocumentDB, Elasticache, ...)
  • Field Details

    • payloadValidationEnabled

      protected boolean payloadValidationEnabled
  • Constructor Details

    • BasePersistenceStore

      public BasePersistenceStore()
  • Method Details

    • configure

      public void configure(IdempotencyConfig config, String functionName)
      Initialize the base persistence layer from the configuration settings
      Parameters:
      config - Idempotency configuration settings
      functionName - The name of the function being decorated
    • saveSuccess

      public void saveSuccess(com.fasterxml.jackson.databind.JsonNode data, Object result, Instant now)
      Save record of function's execution completing successfully
      Parameters:
      data - Payload
      result - the response from the function
    • saveInProgress

      public void saveInProgress(com.fasterxml.jackson.databind.JsonNode data, Instant now, OptionalInt remainingTimeInMs) throws IdempotencyItemAlreadyExistsException
      Save record of function's execution being in progress
      Parameters:
      data - Payload
      now -
      Throws:
      IdempotencyItemAlreadyExistsException
    • deleteRecord

      public void deleteRecord(com.fasterxml.jackson.databind.JsonNode data, Throwable throwable)
      Delete record from the persistence store
      Parameters:
      data - Payload
      throwable - The throwable thrown by the function
    • getRecord

      public DataRecord getRecord(com.fasterxml.jackson.databind.JsonNode data, Instant now) throws IdempotencyValidationException, IdempotencyItemNotFoundException
      Retrieve idempotency key for data provided, fetch from persistence store, and convert to DataRecord.
      Parameters:
      data - Payload
      Returns:
      DataRecord representation of existing record found in persistence store
      Throws:
      IdempotencyValidationException - Payload doesn't match the stored record for the given idempotency key
      IdempotencyItemNotFoundException - Exception thrown if no record exists in persistence store with the idempotency key