diff --git a/src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs b/src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs index 6e6d3ce18..c03a63d0c 100644 --- a/src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs +++ b/src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs @@ -78,11 +78,11 @@ namespace Squidex.Infrastructure.MongoDb.EventStore }); } - public IObservable GetEventsAsync(long lastReceivedPosition = -1) + public IObservable GetEventsAsync(long lastReceivedEventNumber = -1) { return Observable.Create(async (observer, ct) => { - var commitOffset = await GetPreviousOffset(lastReceivedPosition); + var commitOffset = await GetPreviousOffset(lastReceivedEventNumber); await Collection.Find(x => x.EventsOffset >= commitOffset).SortBy(x => x.EventsOffset).ForEachAsync(commit => { @@ -92,7 +92,7 @@ namespace Squidex.Infrastructure.MongoDb.EventStore { eventNumber++; - if (eventNumber > lastReceivedPosition) + if (eventNumber > lastReceivedEventNumber) { var eventData = SimpleMapper.Map(@event, new EventData()); @@ -144,13 +144,13 @@ namespace Squidex.Infrastructure.MongoDb.EventStore return; } - catch (MongoWriteException e) + catch (MongoWriteException ex) { - if (e.Message.IndexOf(eventsOffsetIndex, StringComparison.OrdinalIgnoreCase) >= 0) + if (ex.Message.IndexOf(eventsOffsetIndex, StringComparison.OrdinalIgnoreCase) >= 0) { commit.EventsOffset = await GetEventOffset(); } - else if (e.WriteError?.Category == ServerErrorCategory.DuplicateKey) + else if (ex.WriteError?.Category == ServerErrorCategory.DuplicateKey) { currentVersion = await GetEventStreamOffset(streamName); @@ -165,10 +165,10 @@ namespace Squidex.Infrastructure.MongoDb.EventStore } } - private async Task GetPreviousOffset(long startPosition) + private async Task GetPreviousOffset(long startEventNumber) { var document = - await Collection.Find(x => x.EventsOffset <= startPosition) + await Collection.Find(x => x.EventsOffset <= startEventNumber) .Project(Projection .Include(x => x.EventStreamOffset) .Include(x => x.EventsCount)) diff --git a/src/Squidex.Infrastructure.MongoDb/MongoRepositoryBase.cs b/src/Squidex.Infrastructure.MongoDb/MongoRepositoryBase.cs index bf74dead1..1013c1764 100644 --- a/src/Squidex.Infrastructure.MongoDb/MongoRepositoryBase.cs +++ b/src/Squidex.Infrastructure.MongoDb/MongoRepositoryBase.cs @@ -150,9 +150,9 @@ namespace Squidex.Infrastructure.MongoDb { Database.ListCollections(); } - catch (Exception e) + catch (Exception ex) { - throw new ConfigurationException($"MongoDb connection failed to connect to database {Database.DatabaseNamespace.DatabaseName}", e); + throw new ConfigurationException($"MongoDb connection failed to connect to database {Database.DatabaseNamespace.DatabaseName}", ex); } } } diff --git a/src/Squidex.Infrastructure.Redis/RedisEventNotifier.cs b/src/Squidex.Infrastructure.Redis/RedisEventNotifier.cs index d9a753233..eedef975d 100644 --- a/src/Squidex.Infrastructure.Redis/RedisEventNotifier.cs +++ b/src/Squidex.Infrastructure.Redis/RedisEventNotifier.cs @@ -37,9 +37,9 @@ namespace Squidex.Infrastructure.Redis { inMemoryNotifier.NotifyEventsStored(); } - catch (Exception e) + catch (Exception ex) { - logger.LogError(InfrastructureErrors.InvalidatingReceivedFailed, e, "Failed to receive invalidation message."); + logger.LogError(InfrastructureErrors.InvalidatingReceivedFailed, ex, "Failed to receive invalidation message."); } } @@ -49,9 +49,9 @@ namespace Squidex.Infrastructure.Redis { subscriber.Publish(Channel, RedisValue.Null); } - catch (Exception e) + catch (Exception ex) { - logger.LogError(InfrastructureErrors.InvalidatingReceivedFailed, e, "Failed to send invalidation message"); + logger.LogError(InfrastructureErrors.InvalidatingReceivedFailed, ex, "Failed to send invalidation message"); } } diff --git a/src/Squidex.Infrastructure.Redis/RedisExternalSystem.cs b/src/Squidex.Infrastructure.Redis/RedisExternalSystem.cs index 545bdd99a..4f59c2bd1 100644 --- a/src/Squidex.Infrastructure.Redis/RedisExternalSystem.cs +++ b/src/Squidex.Infrastructure.Redis/RedisExternalSystem.cs @@ -28,9 +28,9 @@ namespace Squidex.Infrastructure.Redis { redis.GetStatus(); } - catch (Exception e) + catch (Exception ex) { - throw new ConfigurationException($"Redis connection failed to connect to database {redis.Configuration}", e); + throw new ConfigurationException($"Redis connection failed to connect to database {redis.Configuration}", ex); } } } diff --git a/src/Squidex.Infrastructure.Redis/RedisInvalidator.cs b/src/Squidex.Infrastructure.Redis/RedisInvalidator.cs index 89e630fa5..8f7aebcca 100644 --- a/src/Squidex.Infrastructure.Redis/RedisInvalidator.cs +++ b/src/Squidex.Infrastructure.Redis/RedisInvalidator.cs @@ -73,9 +73,9 @@ namespace Squidex.Infrastructure.Redis cache.Remove(parts[1]); } } - catch (Exception e) + catch (Exception ex) { - logger.LogError(InfrastructureErrors.InvalidatingReceivedFailed, e, "Failed to receive invalidation message."); + logger.LogError(InfrastructureErrors.InvalidatingReceivedFailed, ex, "Failed to receive invalidation message."); } } @@ -87,9 +87,9 @@ namespace Squidex.Infrastructure.Redis subscriber.Publish(Channel, message); } - catch (Exception e) + catch (Exception ex) { - logger.LogError(InfrastructureErrors.InvalidatingReceivedFailed, e, "Failed to send invalidation message {0}", key); + logger.LogError(InfrastructureErrors.InvalidatingReceivedFailed, ex, "Failed to send invalidation message {0}", key); } } } diff --git a/src/Squidex.Infrastructure/CQRS/Commands/InMemoryCommandBus.cs b/src/Squidex.Infrastructure/CQRS/Commands/InMemoryCommandBus.cs index 69e624390..88d98fe78 100644 --- a/src/Squidex.Infrastructure/CQRS/Commands/InMemoryCommandBus.cs +++ b/src/Squidex.Infrastructure/CQRS/Commands/InMemoryCommandBus.cs @@ -40,9 +40,9 @@ namespace Squidex.Infrastructure.CQRS.Commands context.Succeed(); } } - catch (Exception e) + catch (Exception ex) { - context.Fail(e); + context.Fail(ex); } } diff --git a/src/Squidex.Infrastructure/CQRS/Events/IEventStore.cs b/src/Squidex.Infrastructure/CQRS/Events/IEventStore.cs index 76f73ca91..9feff2f6a 100644 --- a/src/Squidex.Infrastructure/CQRS/Events/IEventStore.cs +++ b/src/Squidex.Infrastructure/CQRS/Events/IEventStore.cs @@ -14,7 +14,7 @@ namespace Squidex.Infrastructure.CQRS.Events { public interface IEventStore { - IObservable GetEventsAsync(long lastReceivedPosition = -1); + IObservable GetEventsAsync(long lastReceivedEventNumber = -1); IObservable GetEventsAsync(string streamName); diff --git a/src/Squidex.Infrastructure/PropertyValue.cs b/src/Squidex.Infrastructure/PropertyValue.cs index b078c2e2f..fa985db39 100644 --- a/src/Squidex.Infrastructure/PropertyValue.cs +++ b/src/Squidex.Infrastructure/PropertyValue.cs @@ -218,11 +218,11 @@ namespace Squidex.Infrastructure { return parser(value.ToString()); } - catch (Exception e) + catch (Exception ex) { string message = $"The property has type '{valueType}' and cannot be casted to '{requestedType}'."; - throw new InvalidCastException(message, e); + throw new InvalidCastException(message, ex); } } diff --git a/src/Squidex.Read.MongoDb/Contents/MongoContentRepository.cs b/src/Squidex.Read.MongoDb/Contents/MongoContentRepository.cs index 6af65cc88..652f33e48 100644 --- a/src/Squidex.Read.MongoDb/Contents/MongoContentRepository.cs +++ b/src/Squidex.Read.MongoDb/Contents/MongoContentRepository.cs @@ -67,9 +67,9 @@ namespace Squidex.Read.MongoDb.Contents { throw new ValidationException("This odata operation is not supported"); } - catch (ODataException e) + catch (ODataException ex) { - throw new ValidationException("Failed to parse query: " + e.Message, e); + throw new ValidationException("Failed to parse query: " + ex.Message, ex); } var entities = await cursor.ToListAsync(); @@ -106,9 +106,9 @@ namespace Squidex.Read.MongoDb.Contents { throw new ValidationException("This odata operation is not supported"); } - catch (ODataException e) + catch (ODataException ex) { - throw new ValidationException("Failed to parse query: " + e.Message, e); + throw new ValidationException("Failed to parse query: " + ex.Message, ex); } result = await cursor.CountAsync(); diff --git a/src/Squidex/Config/Domain/ClusterModule.cs b/src/Squidex/Config/Domain/ClusterModule.cs index f67561229..2a21da8db 100644 --- a/src/Squidex/Config/Domain/ClusterModule.cs +++ b/src/Squidex/Config/Domain/ClusterModule.cs @@ -54,10 +54,19 @@ namespace Squidex.Config.Domain { throw new ConfigurationException("You must specify the Redis connection string in the 'squidex:clusterer:redis:connectionString' configuration section."); } - - builder.Register(c => ConnectionMultiplexer.Connect(connectionString)) - .As() - .SingleInstance(); + + try + { + var connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString); + + builder.RegisterInstance(connectionMultiplexer) + .As() + .SingleInstance(); + } + catch (Exception ex) + { + throw new ConfigurationException($"Redis connection failed to connect to database {connectionString}", ex); + } builder.RegisterType() .As() diff --git a/tests/Squidex.Core.Tests/Schemas/BooleanFieldPropertiesTests.cs b/tests/Squidex.Core.Tests/Schemas/BooleanFieldPropertiesTests.cs index 1949ad093..25371a717 100644 --- a/tests/Squidex.Core.Tests/Schemas/BooleanFieldPropertiesTests.cs +++ b/tests/Squidex.Core.Tests/Schemas/BooleanFieldPropertiesTests.cs @@ -68,9 +68,9 @@ namespace Squidex.Core.Schemas { property.SetValue(sut, value); } - catch (Exception e) + catch (Exception ex) { - throw e.InnerException; + throw ex.InnerException; } }); } diff --git a/tests/Squidex.Core.Tests/Schemas/NumberFieldPropertiesTests.cs b/tests/Squidex.Core.Tests/Schemas/NumberFieldPropertiesTests.cs index d04482f1d..017e38c57 100644 --- a/tests/Squidex.Core.Tests/Schemas/NumberFieldPropertiesTests.cs +++ b/tests/Squidex.Core.Tests/Schemas/NumberFieldPropertiesTests.cs @@ -168,9 +168,9 @@ namespace Squidex.Core.Schemas { property.SetValue(sut, value); } - catch (Exception e) + catch (Exception ex) { - throw e.InnerException; + throw ex.InnerException; } }); } diff --git a/tests/Squidex.Core.Tests/Schemas/StringFieldPropertiesTests.cs b/tests/Squidex.Core.Tests/Schemas/StringFieldPropertiesTests.cs index f5a4f0c6e..4af87e959 100644 --- a/tests/Squidex.Core.Tests/Schemas/StringFieldPropertiesTests.cs +++ b/tests/Squidex.Core.Tests/Schemas/StringFieldPropertiesTests.cs @@ -139,9 +139,9 @@ namespace Squidex.Core.Schemas { property.SetValue(sut, value); } - catch (Exception e) + catch (Exception ex) { - throw e.InnerException; + throw ex.InnerException; } }); }