-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8a5484
commit 9885ea5
Showing
1 changed file
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,10 +1,38 @@ | ||
using Amazon.DynamoDBv2.Model; | ||
using Dynatello.Pipelines; | ||
|
||
namespace Dynatello.Handlers; | ||
|
||
internal sealed class DeleteREquestHandler<TArg, T> : IRequestHandler<TArg, T> | ||
internal sealed class DeleteREquestHandler<TArg, T> : IRequestHandler<TArg, T?> | ||
{ | ||
public Task<T> Send(TArg arg, CancellationToken cancellationToken) | ||
private readonly HandlerOptions _handlerOptions; | ||
private readonly Func<TArg, DeleteItemRequest> _createRequest; | ||
private readonly Func<Dictionary<string, AttributeValue>, T> _createItem; | ||
|
||
internal DeleteREquestHandler( | ||
HandlerOptions handlerOptions, | ||
Func<TArg, DeleteItemRequest> createRequest, | ||
Func<Dictionary<string, AttributeValue>, T> createItem | ||
) | ||
{ | ||
throw new NotImplementedException(); | ||
_handlerOptions = handlerOptions; | ||
_createRequest = createRequest; | ||
_createItem = createItem; | ||
} | ||
public async Task<T?> Send(TArg arg, CancellationToken cancellationToken) | ||
{ | ||
var request = _createRequest(arg); | ||
var response = await request | ||
.SendRequest( | ||
_handlerOptions.RequestsPipelines, | ||
(x, y, z) => y.DeleteItemAsync(x, z), | ||
_handlerOptions.AmazonDynamoDB, | ||
cancellationToken | ||
); | ||
|
||
return request.ReturnValues.IsValueProvided() | ||
? _createItem(response.Attributes) | ||
: default; | ||
} | ||
} | ||
|