Skip to content

Commit f2f2424

Browse files
Merge pull request #860 from TransactionProcessing/task/#855_operator_domain_service_performance
Performance tweaks on domain service
2 parents c0f8595 + 727726c commit f2f2424

3 files changed

Lines changed: 103 additions & 89 deletions

File tree

TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,19 @@ public async Task<Result> RecordTransaction(FloatActivityCommands.RecordTransact
186186

187187
public static class DomainServiceHelper
188188
{
189+
public static async Task<Result<TAggregate>> GetAggregateOrFailure<TAggregate>(Func<CancellationToken, Task<Result<TAggregate>>> fetchFunc,
190+
Guid aggregateId,
191+
CancellationToken cancellationToken,
192+
Boolean isNotFoundError = true) where TAggregate : Aggregate, new()
193+
{
194+
Result<TAggregate> result = await fetchFunc(cancellationToken);
195+
return result.IsFailed switch
196+
{
197+
true => DomainServiceHelper.HandleGetAggregateResult(result, aggregateId, isNotFoundError),
198+
_ => Result.Success(result.Data)
199+
};
200+
}
201+
189202
public static Result<T> HandleGetAggregateResult<T>(Result<T> result, Guid aggregateId, bool isNotFoundError = true)
190203
where T : Aggregate, new() // Constraint: T is a subclass of Aggregate and has a parameterless constructor
191204
{

0 commit comments

Comments
 (0)