You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Idemp should be fixed, test isnt
* Fix some of the tests. Need to go through the rest still
* Add some docs
* Update powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/DataRecord.java
Co-authored-by: Jérôme Van Der Linden <[email protected]>
* Address review comment
---------
Co-authored-by: Jérôme Van Der Linden <[email protected]>
Copy file name to clipboardExpand all lines: powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/DataRecord.java
+21
Original file line number
Diff line number
Diff line change
@@ -26,9 +26,30 @@
26
26
publicclassDataRecord {
27
27
privatefinalStringidempotencyKey;
28
28
privatefinalStringstatus;
29
+
30
+
/**
31
+
* This field is controlling how long the result of the idempotent
32
+
* event is cached. It is stored in _seconds since epoch_.
33
+
*
34
+
* DynamoDB's TTL mechanism is used to remove the record once the
35
+
* expiry has been reached, and subsequent execution of the request
36
+
* will be permitted. The user must configure this on their table.
37
+
*/
29
38
privatefinallongexpiryTimestamp;
30
39
privatefinalStringresponseData;
31
40
privatefinalStringpayloadHash;
41
+
42
+
/**
43
+
* The in-progress field is set to the remaining lambda execution time
44
+
* when the record is created.
45
+
* This field is stored in _milliseconds since epoch_.
46
+
*
47
+
* This ensures that:
48
+
*
49
+
* 1/ other concurrently executing requests are blocked from starting
50
+
* 2/ if a lambda times out, subsequent requests will be allowed again, despite
51
+
* the fact that the idempotency record is already in the table
Copy file name to clipboardExpand all lines: powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/DynamoDBPersistenceStore.java
+15-1
Original file line number
Diff line number
Diff line change
@@ -126,6 +126,19 @@ public DataRecord getRecord(String idempotencyKey) throws IdempotencyItemNotFoun
126
126
returnitemToRecord(response.item());
127
127
}
128
128
129
+
/**
130
+
* Store's the given idempotency record in the DDB store. If there
131
+
* is an existing record that has expired - either due to the
132
+
* cache expiry or due to the in_progress_expiry - the record
133
+
* will be overwritten and the idempotent operation can continue.
134
+
*
135
+
* <b>Note: This method writes only expiry and status information - not
.conditionExpression("attribute_not_exists(#id) OR #expiry < :now OR (attribute_exists(#in_progress_expiry) AND #in_progress_expiry < :now AND #status = :inprogress)")
177
+
.conditionExpression("attribute_not_exists(#id) OR #expiry < :now OR (attribute_exists(#in_progress_expiry) AND #in_progress_expiry < :now_milliseconds AND #status = :inprogress)")
Copy file name to clipboardExpand all lines: powertools-idempotency/src/test/java/software/amazon/lambda/powertools/idempotency/persistence/DynamoDBPersistenceStoreTest.java
+6-6
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ public void putRecord_shouldCreateRecordInDynamoDB_IfLambdaWasInProgressAndTimed
0 commit comments