-
Notifications
You must be signed in to change notification settings - Fork 26
feat: Add Idempotency Package #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hjgraca
merged 40 commits into
aws-powertools:develop
from
hossambarakat:feature/idempotency
Jun 8, 2023
Merged
Changes from 17 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
337cf1e
Add idempotency module to solution
89c680a
Add documentation
7abb323
Consistent project files
eee318c
Update test names to follow the convention <MethodName>_<Condition>_<…
97459e6
Merge branch 'develop' into feature/idempotency
036bb0e
Fix HashFunction reference documentation
483e5cc
Merge branch 'develop' into feature/idempotency
73af08d
Use idiomatic C# and terser configurations for Idempotency
5f2bf40
Add more comments and fix null reference warnings
127f52c
Add NullLog as default logger
adcbe97
Use UniversalWrapperAspect as opposed to custom IdempotentAspect
7e1e7ee
Add missing documentation
ef81092
Fix Null Reference warning
b86e3f1
Use Instance as property
432b65f
revert removed comment
8b0395f
Fix minor issues in documentation
abf4d50
Merge branch 'awslabs:develop' into feature/idempotency
hossambarakat 82ebd43
Merge branch 'develop' of https://github.com/awslabs/aws-lambda-power…
hjgraca 526310f
Remove references to Newtonsoft, remove testcontainers and persistenc…
hjgraca bf66bc0
fix csproj
hjgraca 4a96564
Merge remote-tracking branch 'origin/develop' into feature/idempotency
hjgraca 501460b
Merge remote-tracking branch 'origin/develop' into feature/idempotency
hjgraca e878f14
Merge remote-tracking branch 'origin/develop' into feature/idempotency
hjgraca 03afc4d
remove null. Code updates to var. Set execution environment tests
hjgraca 971bec7
Merge remote-tracking branch 'origin/develop' into feature/idempotency
hjgraca 877f082
remove constructor and skip e2e tests for CI
hjgraca 02590a4
update test packages. remove newtonsoft
hjgraca 41a6f6f
Upgrade Amazon.Lambda.APIGatewayEvents this changed the json so needs…
hjgraca dd6521f
move constants. Enable integration tests dynamo. Code inspection fixes
hjgraca c2167a1
forgot to skip tests
hjgraca 62ed433
adding integration tests. added testcontainers. refactor for single c…
hjgraca 2424868
Refactor integration tests. Now all run in TestContainer
hjgraca b6b3c7f
Refactor tests. Remove direct environment check for Idempotency Disab…
hjgraca 983234f
delete file
hjgraca 45c746a
Refactor. Enabled Idempotency on Sync handlers. Refactor unit tests w…
hjgraca be9bcdc
Remove LogTo method, ILog and Debug logging
hjgraca 3606455
Add comments to private fields and methods
hjgraca 7479811
Changes from feedback
hjgraca ae021c6
remove todo
hjgraca 33de0e1
Addressing analysed warnings.
hjgraca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
libraries/src/AWS.Lambda.Powertools.Idempotency/AWS.Lambda.Powertools.Idempotency.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<LangVersion>default</LangVersion> | ||
<PackageId>AWS.Lambda.Powertools.Idempotency</PackageId> | ||
<Version>0.0.1</Version> | ||
<Nullable>enable</Nullable> | ||
<Authors>Amazon Web Services</Authors> | ||
<Company>Amazon.com, Inc</Company> | ||
<Title>AWS Lambda Powertools for .NET</Title> | ||
<Description>AWS Lambda Powertools for .NET - Logging package.</Description> | ||
<Copyright>Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.</Copyright> | ||
<RepositoryUrl>https://github.com/awslabs/aws-lambda-powertools-dotnet</RepositoryUrl> | ||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
<PackageTags>AWS;Amazon;Lambda;Powertools</PackageTags> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<PackageIconUrl>https://sdk-for-net.amazonwebservices.com/images/AWSLogo128x128.png</PackageIconUrl> | ||
<PackageIcon>AWSLogo128x128.png</PackageIcon> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<AssemblyName>AWS.Lambda.Powertools.Idempotency</AssemblyName> | ||
<RootNamespace>AWS.Lambda.Powertools.Idempotency</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="README.md" Pack="true" PackagePath="\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" /> | ||
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.3.43" /> | ||
<PackageReference Include="JmesPath.Net" Version="1.0.182" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
hjgraca marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AWS.Lambda.Powertools.Common\AWS.Lambda.Powertools.Common.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="../../AWSLogo128x128.png" Pack="true" Visible="false" PackagePath="" /> | ||
</ItemGroup> | ||
|
||
</Project> |
44 changes: 44 additions & 0 deletions
44
...src/AWS.Lambda.Powertools.Idempotency/Exceptions/IdempotencyAlreadyInProgressException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace AWS.Lambda.Powertools.Idempotency.Exceptions; | ||
|
||
/// <summary> | ||
/// This exception is thrown when the same payload is sent | ||
/// while the previous one was not yet fully stored in the persistence layer (marked as COMPLETED). | ||
/// Implements the <see cref="System.Exception" /> | ||
/// </summary> | ||
/// <seealso cref="System.Exception" /> | ||
public class IdempotencyAlreadyInProgressException: Exception | ||
{ | ||
/// <summary> | ||
/// Creates a new IdempotencyAlreadyInProgressException | ||
/// </summary> | ||
public IdempotencyAlreadyInProgressException() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyAlreadyInProgressException(string? message) : base(message) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyAlreadyInProgressException(string? message, Exception? innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ies/src/AWS.Lambda.Powertools.Idempotency/Exceptions/IdempotencyConfigurationException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace AWS.Lambda.Powertools.Idempotency.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when Idempotency is not well configured: | ||
/// - An annotated method does not return anything | ||
/// - An annotated method does not use Task as return value | ||
/// - An annotated method does not have parameters | ||
/// </summary> | ||
public class IdempotencyConfigurationException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates a new IdempotencyConfigurationException | ||
/// </summary> | ||
public IdempotencyConfigurationException() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyConfigurationException(string? message) : base(message) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyConfigurationException(string? message, Exception? innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...src/AWS.Lambda.Powertools.Idempotency/Exceptions/IdempotencyInconsistentStateException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace AWS.Lambda.Powertools.Idempotency.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception can happen under rare but expected cases | ||
/// when persistent state changes in the small-time between put and get requests. | ||
/// </summary> | ||
public class IdempotencyInconsistentStateException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates a new IdempotencyInconsistentStateException | ||
/// </summary> | ||
public IdempotencyInconsistentStateException() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyInconsistentStateException(string? message) : base(message) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyInconsistentStateException(string? message, Exception? innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...src/AWS.Lambda.Powertools.Idempotency/Exceptions/IdempotencyItemAlreadyExistsException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace AWS.Lambda.Powertools.Idempotency.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when trying to store an item which already exists. | ||
/// </summary> | ||
public class IdempotencyItemAlreadyExistsException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates a new IdempotencyItemAlreadyExistsException | ||
/// </summary> | ||
public IdempotencyItemAlreadyExistsException() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyItemAlreadyExistsException(string? message) : base(message) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyItemAlreadyExistsException(string? message, Exception? innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ries/src/AWS.Lambda.Powertools.Idempotency/Exceptions/IdempotencyItemNotFoundException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace AWS.Lambda.Powertools.Idempotency.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when the item was not found in the persistence store. | ||
/// </summary> | ||
public class IdempotencyItemNotFoundException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates a new IdempotencyItemNotFoundException | ||
/// </summary> | ||
public IdempotencyItemNotFoundException() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyItemNotFoundException(string? message) : base(message) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyItemNotFoundException(string? message, Exception? innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
libraries/src/AWS.Lambda.Powertools.Idempotency/Exceptions/IdempotencyKeyException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace AWS.Lambda.Powertools.Idempotency.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown only when using <see cref="IdempotencyOptions.ThrowOnNoIdempotencyKey"/> | ||
/// and if a key could not be found in the event (for example when having a bad JMESPath configured) | ||
/// </summary> | ||
public class IdempotencyKeyException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates a new IdempotencyKeyException | ||
/// </summary> | ||
public IdempotencyKeyException() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyKeyException(string? message) : base(message) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IdempotencyKeyException(string? message, Exception? innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.