Browse Source

Small refactoring.

pull/349/head
Sebastian Stehle 7 years ago
parent
commit
752cbfc431
  1. 1
      src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs
  2. 8
      src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs

1
src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs

@ -15,7 +15,6 @@ namespace Squidex.Infrastructure.EventSourcing
{
public partial class MongoEventStore : MongoRepositoryBase<MongoEventCommit>, IEventStore
{
private const int MaxCommitSize = 10;
private static readonly FieldDefinition<MongoEventCommit, BsonTimestamp> TimestampField = Fields.Build(x => x.Timestamp);
private static readonly FieldDefinition<MongoEventCommit, long> EventsCountField = Fields.Build(x => x.EventsCount);
private static readonly FieldDefinition<MongoEventCommit, long> EventStreamOffsetField = Fields.Build(x => x.EventStreamOffset);

8
src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs

@ -17,6 +17,7 @@ namespace Squidex.Infrastructure.EventSourcing
public partial class MongoEventStore
{
private const int MaxWriteAttempts = 20;
private const int MaxCommitSize = 10;
private static readonly BsonTimestamp EmptyTimestamp = new BsonTimestamp(0);
public Task DeleteStreamAsync(string streamName)
@ -32,13 +33,12 @@ namespace Squidex.Infrastructure.EventSourcing
public async Task AppendAsync(Guid commitId, string streamName, long expectedVersion, ICollection<EventData> events)
{
Guard.LessThan(events.Count, MaxCommitSize, "events.Count");
Guard.GreaterEquals(expectedVersion, EtagVersion.Any, nameof(expectedVersion));
Guard.NotNullOrEmpty(streamName, nameof(streamName));
Guard.NotNull(events, nameof(events));
using (Profiler.TraceMethod<MongoEventStore>())
{
Guard.GreaterEquals(expectedVersion, EtagVersion.Any, nameof(expectedVersion));
Guard.NotNullOrEmpty(streamName, nameof(streamName));
Guard.NotNull(events, nameof(events));
if (events.Count == 0)
{
return;

Loading…
Cancel
Save