From 752cbfc431109d01205b2b381ecabb8f4da55084 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 24 Feb 2019 20:41:07 +0100 Subject: [PATCH] Small refactoring. --- .../EventSourcing/MongoEventStore.cs | 1 - .../EventSourcing/MongoEventStore_Writer.cs | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs b/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs index fe20956ed..c33c11f40 100644 --- a/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs +++ b/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs @@ -15,7 +15,6 @@ namespace Squidex.Infrastructure.EventSourcing { public partial class MongoEventStore : MongoRepositoryBase, IEventStore { - private const int MaxCommitSize = 10; private static readonly FieldDefinition TimestampField = Fields.Build(x => x.Timestamp); private static readonly FieldDefinition EventsCountField = Fields.Build(x => x.EventsCount); private static readonly FieldDefinition EventStreamOffsetField = Fields.Build(x => x.EventStreamOffset); diff --git a/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs b/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs index aa0707f2e..83f0416e7 100644 --- a/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs +++ b/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 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()) { - Guard.GreaterEquals(expectedVersion, EtagVersion.Any, nameof(expectedVersion)); - Guard.NotNullOrEmpty(streamName, nameof(streamName)); - Guard.NotNull(events, nameof(events)); - if (events.Count == 0) { return;