forked from huysentruitw/Aggregator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IEventStore.cs
37 lines (34 loc) · 1.53 KB
/
IEventStore.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Threading.Tasks;
using Aggregator.Command;
namespace Aggregator.Persistence
{
/// <summary>
/// Interface for an event store implementation.
/// </summary>
/// <typeparam name="TIdentifier">The identifier type.</typeparam>
/// <typeparam name="TEventBase">The event base type.</typeparam>
public interface IEventStore<in TIdentifier, TEventBase>
where TIdentifier : IEquatable<TIdentifier>
{
/// <summary>
/// Checks if an aggregate root with the given identifier exists.
/// </summary>
/// <param name="identifier">The aggregate root identifier.</param>
/// <returns>True in case an aggregate root with the given identifier exists, false when not.</returns>
Task<bool> Contains(TIdentifier identifier);
/// <summary>
/// Get events for a certain aggregate root.
/// </summary>
/// <param name="identifier">The aggregate root identifier.</param>
/// <param name="minimumVersion">The minimum version.</param>
/// <returns>The events starting at minimumVersion.</returns>
Task<TEventBase[]> GetEvents(TIdentifier identifier, long minimumVersion = 0);
/// <summary>
/// Begins a disposable transaction.
/// </summary>
/// <param name="context">The command handling context.</param>
/// <returns>A disposable event store transaction.</returns>
IEventStoreTransaction<TIdentifier, TEventBase> BeginTransaction(CommandHandlingContext context);
}
}