generated from Nexus-Mods/NexusMods.App.Template
-
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.
Rework everything to work via transactions
- Loading branch information
Showing
21 changed files
with
498 additions
and
182 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
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 |
---|---|---|
@@ -1,34 +1,20 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace NexusMods.EventSourcing.Abstractions; | ||
|
||
/// <summary> | ||
/// A interface for a transaction that can be used to add new events to storage. | ||
/// A context for adding events to an aggregate event that will apply the events together. | ||
/// </summary> | ||
public interface ITransaction : IDisposable | ||
{ | ||
/// <summary> | ||
/// Confirms the transaction and commits the changes to the underlying storage. | ||
/// Adds the event to the transaction, but does not apply it. | ||
/// </summary> | ||
/// <returns></returns> | ||
public ValueTask CommitAsync(); | ||
/// <param name="event"></param> | ||
public void Add(IEvent @event); | ||
|
||
/// <summary> | ||
/// Gets the current state of an entity. | ||
/// Commits the transaction, applying all events | ||
/// </summary> | ||
/// <param name="entityId"></param> | ||
/// <typeparam name="T"></typeparam> | ||
/// <returns></returns> | ||
public T Retrieve<T>(EntityId<T> entityId) where T : IEntity; | ||
|
||
/// <summary> | ||
/// Adds a new event to the transaction, this will also update the current | ||
/// entity states | ||
/// </summary> | ||
/// <param name="entityId"></param> | ||
/// <typeparam name="T"></typeparam> | ||
/// <returns></returns> | ||
public ValueTask Add<T>(T eventToAdd) where T : IEvent; | ||
|
||
public TransactionId Commit(); | ||
} |
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.