mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Implements domain events queue processing and eventual consistency
This commit is contained in:
1 parent
f96cfa4a2f
commit
80e2ce0f82
10 files changed
+198
-9
No files matched your search
@@ -1,3 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Events;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Models.Core;
|
||||
|
||||
/// <summary>
|
||||
@@ -6,6 +11,8 @@ namespace Lumina.Domain.Common.Models.Core;
|
||||
/// <typeparam name="TId">The type representing the unique identifier for the Aggregate Root. It should be a non-nullable type.</typeparam>
|
||||
public abstract class AggregateRoot<TId> : Entity<TId> where TId : notnull
|
||||
{
|
||||
protected readonly List<IDomainEvent> _domainEvents = [];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AggregateRoot{TId}"/> class.
|
||||
/// </summary>
|
||||
@@ -22,4 +29,15 @@ public abstract class AggregateRoot<TId> : Entity<TId> where TId : notnull
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves and clears all domain events associated with this aggregate root.
|
||||
/// </summary>
|
||||
/// <returns>A list of all domain events that were raised by this aggregate root.</returns>
|
||||
public List<IDomainEvent> PopDomainEvents()
|
||||
{
|
||||
List<IDomainEvent> domainEventsCopy = [.. _domainEvents];
|
||||
_domainEvents.Clear();
|
||||
return domainEventsCopy;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user