-
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.
Added IStore and IStoreRepository to store generic objects (#64)
Co-authored-by: Dmitriy Melnychenko <dmitriy.melnichenko@techfabric.com>
- Loading branch information
Showing
27 changed files
with
510 additions
and
310 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 |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
branches: [ "main" ] | ||
|
||
env: | ||
PACKAGE_VERSION: 0.1.4 | ||
PACKAGE_VERSION: 0.1.5 | ||
|
||
jobs: | ||
|
||
|
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
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
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,12 @@ | ||
namespace CloudFabric.EventSourcing.Domain; | ||
|
||
/// <summary> | ||
/// Repository that provides possibility of storing typed objects, | ||
/// due to requirements to save non 'evented' aggregates items outside of EventStore. | ||
/// </summary> | ||
public interface IStoreRepository | ||
{ | ||
Task UpsertItem<T>(string id, string partitionKey, T item, CancellationToken cancellationToken = default); | ||
|
||
Task<T?> LoadItem<T>(string id, string partitionKey, CancellationToken cancellationToken = default); | ||
} |
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,33 @@ | ||
using CloudFabric.EventSourcing.EventStore; | ||
|
||
namespace CloudFabric.EventSourcing.Domain; | ||
|
||
public class StoreRepository : IStoreRepository | ||
{ | ||
private readonly IStore _store; | ||
|
||
public StoreRepository(IStore store) | ||
{ | ||
_store = store; | ||
} | ||
|
||
public async Task UpsertItem<TItem>(string id, string partitionKey, TItem item, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(id)) | ||
{ | ||
throw new ArgumentNullException(nameof(id)); | ||
} | ||
|
||
await _store.UpsertItem(id, partitionKey, item, cancellationToken); | ||
} | ||
|
||
public async Task<TItem?> LoadItem<TItem>(string id, string partitionKey, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(id)) | ||
{ | ||
throw new ArgumentNullException(nameof(id)); | ||
} | ||
|
||
return await _store.LoadItem<TItem?>(id, partitionKey, cancellationToken); | ||
} | ||
} |
6 changes: 0 additions & 6 deletions
6
CloudFabric.EventSourcing.EventStore/Enums/ItemsEventStoreNameSuffix.cs
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
CloudFabric.EventSourcing.EventStore/Enums/ItemsStoreNameDefaults.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,9 @@ | ||
namespace CloudFabric.EventSourcing.EventStore.Enums; | ||
|
||
public static class ItemsStoreNameDefaults | ||
{ | ||
public const string TableNameSuffix = "-item"; | ||
|
||
public static string AddDefaultTableNameSuffix(string tableName) | ||
=> string.Concat(tableName, TableNameSuffix); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace CloudFabric.EventSourcing.EventStore; | ||
|
||
public interface IStore | ||
{ | ||
Task Initialize(CancellationToken cancellationToken = default); | ||
|
||
Task DeleteAll(CancellationToken cancellationToken = default); | ||
|
||
Task UpsertItem<T>(string id, string partitionKey, T item, CancellationToken cancellationToken = default); | ||
|
||
Task<T?> LoadItem<T>(string id, string partitionKey, CancellationToken cancellationToken = default); | ||
} |
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.