-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Azure 테이블 저장소 기반 이벤트 저장소 구현체가 영속 이벤트와 발행 대기 이벤트를 하나의 파티션에 기록해 두 이벤트의 기록 작업이 원자성을 가지도록 변경한다. Issue: #28
- Loading branch information
Showing
15 changed files
with
617 additions
and
466 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
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
81 changes: 81 additions & 0 deletions
81
source/Khala.EventSourcing.Azure/EventSourcing/Azure/Correlation.cs
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
namespace Khala.EventSourcing.Azure | ||
{ | ||
using System; | ||
using Microsoft.WindowsAzure.Storage.Table; | ||
|
||
public class Correlation : AggregateEntity | ||
{ | ||
public Guid CorrelationId { get; set; } | ||
|
||
public static string GetRowKey(Guid correlationId) | ||
{ | ||
if (correlationId == Guid.Empty) | ||
{ | ||
throw new ArgumentException("Value cannot be empty.", nameof(correlationId)); | ||
} | ||
|
||
return $"Correlation-{correlationId:n}"; | ||
} | ||
|
||
public static Correlation Create( | ||
Type sourceType, | ||
Guid sourceId, | ||
Guid correlationId) | ||
{ | ||
if (sourceType == null) | ||
{ | ||
throw new ArgumentNullException(nameof(sourceType)); | ||
} | ||
|
||
if (sourceId == Guid.Empty) | ||
{ | ||
throw new ArgumentException("Value cannot be empty.", nameof(sourceId)); | ||
} | ||
|
||
if (correlationId == Guid.Empty) | ||
{ | ||
throw new ArgumentException("Value cannot be empty.", nameof(correlationId)); | ||
} | ||
|
||
return new Correlation | ||
{ | ||
PartitionKey = GetPartitionKey(sourceType, sourceId), | ||
RowKey = GetRowKey(correlationId), | ||
CorrelationId = correlationId, | ||
}; | ||
} | ||
|
||
public static string GetFilter( | ||
Type sourceType, | ||
Guid sourceId, | ||
Guid correlationId) | ||
{ | ||
if (sourceType == null) | ||
{ | ||
throw new ArgumentNullException(nameof(sourceType)); | ||
} | ||
|
||
if (sourceId == Guid.Empty) | ||
{ | ||
throw new ArgumentException("Value cannot be empty.", nameof(sourceId)); | ||
} | ||
|
||
if (correlationId == Guid.Empty) | ||
{ | ||
throw new ArgumentException("Value cannot be empty.", nameof(correlationId)); | ||
} | ||
|
||
string partitionCondition = TableQuery.GenerateFilterCondition( | ||
nameof(PartitionKey), | ||
QueryComparisons.Equal, | ||
GetPartitionKey(sourceType, sourceId)); | ||
|
||
string rowCondition = TableQuery.GenerateFilterCondition( | ||
nameof(RowKey), | ||
QueryComparisons.Equal, | ||
GetRowKey(correlationId)); | ||
|
||
return TableQuery.CombineFilters(partitionCondition, TableOperators.And, rowCondition); | ||
} | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
source/Khala.EventSourcing.Azure/EventSourcing/Azure/CorrelationEntity.cs
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.