Skip to content

Commit da20909

Browse files
committed
Added comments with en explanation for the EventStoreDBSubscriptionCheckpointRepository
1 parent 3c1b280 commit da20909

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Core.EventStoreDB/Events/AggregateStreamExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using Core.Aggregates;
54
using Core.Events;
65
using Core.EventStoreDB.Serialization;
76
using Core.Projections;

Core.EventStoreDB/Subscriptions/EventStoreDBSubscriptionCheckpointRepository.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public async ValueTask Store(string subscriptionId, ulong position, Cancellation
4646

4747
try
4848
{
49+
// store new checkpoint expecting stream to exist
4950
await eventStoreClient.AppendToStreamAsync(
5051
streamName,
5152
StreamState.StreamExists,
@@ -55,13 +56,17 @@ await eventStoreClient.AppendToStreamAsync(
5556
}
5657
catch (WrongExpectedVersionException)
5758
{
59+
// WrongExpectedVersionException means that stream did not exist
60+
// Set the checkpoint stream to have at most 1 event
61+
// using stream metadata $maxCount property
5862
await eventStoreClient.SetStreamMetadataAsync(
5963
streamName,
6064
StreamState.NoStream,
6165
new StreamMetadata(1),
6266
cancellationToken: ct
6367
);
6468

69+
// append event again expecting stream to not exist
6570
await eventStoreClient.AppendToStreamAsync(
6671
streamName,
6772
StreamState.NoStream,

0 commit comments

Comments
 (0)