Browse Source

Config fixes

pull/1/head
Sebastian 9 years ago
parent
commit
92be23f7fc
  1. 16
      src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs
  2. 4
      src/Squidex.Infrastructure.MongoDb/MongoRepositoryBase.cs
  3. 8
      src/Squidex.Infrastructure.Redis/RedisEventNotifier.cs
  4. 4
      src/Squidex.Infrastructure.Redis/RedisExternalSystem.cs
  5. 8
      src/Squidex.Infrastructure.Redis/RedisInvalidator.cs
  6. 4
      src/Squidex.Infrastructure/CQRS/Commands/InMemoryCommandBus.cs
  7. 2
      src/Squidex.Infrastructure/CQRS/Events/IEventStore.cs
  8. 4
      src/Squidex.Infrastructure/PropertyValue.cs
  9. 8
      src/Squidex.Read.MongoDb/Contents/MongoContentRepository.cs
  10. 11
      src/Squidex/Config/Domain/ClusterModule.cs
  11. 4
      tests/Squidex.Core.Tests/Schemas/BooleanFieldPropertiesTests.cs
  12. 4
      tests/Squidex.Core.Tests/Schemas/NumberFieldPropertiesTests.cs
  13. 4
      tests/Squidex.Core.Tests/Schemas/StringFieldPropertiesTests.cs

16
src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs

@ -78,11 +78,11 @@ namespace Squidex.Infrastructure.MongoDb.EventStore
});
}
public IObservable<StoredEvent> GetEventsAsync(long lastReceivedPosition = -1)
public IObservable<StoredEvent> GetEventsAsync(long lastReceivedEventNumber = -1)
{
return Observable.Create<StoredEvent>(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<long> GetPreviousOffset(long startPosition)
private async Task<long> GetPreviousOffset(long startEventNumber)
{
var document =
await Collection.Find(x => x.EventsOffset <= startPosition)
await Collection.Find(x => x.EventsOffset <= startEventNumber)
.Project<BsonDocument>(Projection
.Include(x => x.EventStreamOffset)
.Include(x => x.EventsCount))

4
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);
}
}
}

8
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");
}
}

4
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);
}
}
}

8
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);
}
}
}

4
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);
}
}

2
src/Squidex.Infrastructure/CQRS/Events/IEventStore.cs

@ -14,7 +14,7 @@ namespace Squidex.Infrastructure.CQRS.Events
{
public interface IEventStore
{
IObservable<StoredEvent> GetEventsAsync(long lastReceivedPosition = -1);
IObservable<StoredEvent> GetEventsAsync(long lastReceivedEventNumber = -1);
IObservable<StoredEvent> GetEventsAsync(string streamName);

4
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);
}
}

8
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();

11
src/Squidex/Config/Domain/ClusterModule.cs

@ -55,9 +55,18 @@ 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))
try
{
var connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString);
builder.RegisterInstance(connectionMultiplexer)
.As<IConnectionMultiplexer>()
.SingleInstance();
}
catch (Exception ex)
{
throw new ConfigurationException($"Redis connection failed to connect to database {connectionString}", ex);
}
builder.RegisterType<RedisEventNotifier>()
.As<IEventNotifier>()

4
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;
}
});
}

4
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;
}
});
}

4
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;
}
});
}

Loading…
Cancel
Save