Class BasePersistenceStore
Persistence layer that will store the idempotency result. Base implementation. See DynamoDBPersistenceStore for an implementation (default one) Extend this class to use your own implementation (DocumentDB, ElastiCache, ...)
Implements
Inherited Members
Namespace: AWS.Lambda.Powertools.Idempotency.Persistence
Assembly: AWS.Lambda.Powertools.Idempotency.dll
Syntax
public abstract class BasePersistenceStore : IPersistenceStore
Fields
PayloadValidationEnabled
Boolean to indicate whether or not payload validation is enabled
Declaration
protected bool PayloadValidationEnabled
Field Value
Type | Description |
---|---|
bool |
Methods
Configure(IdempotencyOptions, string, string)
Initialize the base persistence layer from the configuration settings
Declaration
public void Configure(IdempotencyOptions idempotencyOptions, string functionName, string keyPrefix)
Parameters
Type | Name | Description |
---|---|---|
IdempotencyOptions | idempotencyOptions | Idempotency configuration settings |
string | functionName | The name of the function being decorated |
string | keyPrefix |
DeleteRecord(string)
Remove item from persistence store
Declaration
public abstract Task DeleteRecord(string idempotencyKey)
Parameters
Type | Name | Description |
---|---|---|
string | idempotencyKey | idempotencyKey the key of the record |
Returns
Type | Description |
---|---|
Task |
DeleteRecord(JsonDocument, Exception)
Delete record from the persistence store
Declaration
public virtual Task DeleteRecord(JsonDocument data, Exception throwable)
Parameters
Type | Name | Description |
---|---|---|
JsonDocument | data | Payload |
Exception | throwable | The throwable thrown by the function |
Returns
Type | Description |
---|---|
Task |
GetRecord(string)
Retrieve item from persistence store using idempotency key and return it as a DataRecord instance.
Declaration
public abstract Task<DataRecord> GetRecord(string idempotencyKey)
Parameters
Type | Name | Description |
---|---|---|
string | idempotencyKey | idempotencyKey the key of the record |
Returns
Type | Description |
---|---|
Task<DataRecord> | DataRecord representation of existing record found in persistence store |
Exceptions
Type | Condition |
---|---|
IdempotencyItemNotFoundException | Exception thrown if no record exists in persistence store with the idempotency key |
GetRecord(JsonDocument, DateTimeOffset)
Retrieve idempotency key for data provided, fetch from persistence store, and convert to DataRecord.
Declaration
public virtual Task<DataRecord> GetRecord(JsonDocument data, DateTimeOffset now)
Parameters
Type | Name | Description |
---|---|---|
JsonDocument | data | Payload |
DateTimeOffset | now |
Returns
Type | Description |
---|---|
Task<DataRecord> | DataRecord representation of existing record found in persistence store |
PutRecord(DataRecord, DateTimeOffset)
Add a DataRecord to persistence store if it does not already exist with that key. Stores the given idempotency record in the DDB store. If there is an existing record that has expired - either due to the cache expiry or due to the in_progress_expiry - the record will be overwritten and the idempotent operation can continue. Note: This method writes only expiry and status information - not the results of the operation itself.
Declaration
public abstract Task PutRecord(DataRecord record, DateTimeOffset now)
Parameters
Type | Name | Description |
---|---|---|
DataRecord | record | record DataRecord instance |
DateTimeOffset | now |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
IdempotencyItemAlreadyExistsException | if a non-expired entry already exists. |
SaveInProgress(JsonDocument, DateTimeOffset, double?)
Save record of function's execution being in progress
Declaration
public virtual Task SaveInProgress(JsonDocument data, DateTimeOffset now, double? remainingTimeInMs)
Parameters
Type | Name | Description |
---|---|---|
JsonDocument | data | Payload |
DateTimeOffset | now | The current date time |
double? | remainingTimeInMs | The remaining time from lambda execution |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
IdempotencyItemAlreadyExistsException |
SaveSuccess(JsonDocument, object, DateTimeOffset)
Save record of function's execution completing successfully
Declaration
public virtual Task SaveSuccess(JsonDocument data, object result, DateTimeOffset now)
Parameters
Type | Name | Description |
---|---|---|
JsonDocument | data | Payload |
object | result | the response from the function |
DateTimeOffset | now | The current date time |
Returns
Type | Description |
---|---|
Task |
UpdateRecord(DataRecord)
Update item in persistence store
Declaration
public abstract Task UpdateRecord(DataRecord record)
Parameters
Type | Name | Description |
---|---|---|
DataRecord | record | DataRecord instance |
Returns
Type | Description |
---|---|
Task |