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
Add support for response hooks in idempotency configuration
- Introduce ResponseHook delegate to IdempotencyOptions and builder - Invoke response hook on idempotent responses in IdempotencyAspectHandler - Update documentation with usage examples and best practices for response hooks - Add integration tests for response hook execution and exception handling - Improve XML doc comments for builder and persistence store
You can set up a response hook in the Idempotency configuration to manipulate the returned data when an operation is idempotent. The hook function will be called with the current deserialized response object and the Idempotency `DataRecord`.
852
+
853
+
#### Using Response Hooks
854
+
855
+
The example below shows how to append HTTP headers to an `APIGatewayProxyResponse`:
The response hook is called after de-serialization so the payload you process will be the de-serialized Java object.
881
+
882
+
#### Being a good citizen
883
+
884
+
When using response hooks to manipulate returned data from idempotent operations, it's important to follow best practices to avoid introducing complexity or issues. Keep these guidelines in mind:
885
+
886
+
1.**Response hook works exclusively when operations are idempotent.** The hook will not be called when an operation is not idempotent, or when the idempotent logic fails.
887
+
888
+
2.**Catch and Handle Exceptions.** Your response hook code should catch and handle any exceptions that may arise from your logic. Unhandled exceptions will cause the Lambda function to fail unexpectedly.
889
+
890
+
3.**Keep Hook Logic Simple** Response hooks should consist of minimal and straightforward logic for manipulating response data. Avoid complex conditional branching and aim for hooks that are easy to reason about.
891
+
892
+
849
893
## AOT Support
850
894
851
895
Native AOT trims your application code as part of the compilation to ensure that the binary is as small as possible. .NET 8 for Lambda provides improved trimming support compared to previous versions of .NET.
@@ -921,4 +965,4 @@ When testing your code, you may wish to disable the idempotency logic altogether
921
965
## Extra resources
922
966
923
967
If you're interested in a deep dive on how Amazon uses idempotency when building our APIs, check out
0 commit comments