Browse Source

Minor refactorings.

pull/130/head
Sebastian Stehle 9 years ago
parent
commit
ecc8c7fc6c
  1. 15
      Squidex.Infrastructure.EventStore/Squidex.Infrastructure.EventStore.csproj
  2. 28
      Squidex.sln
  3. 2
      src/Squidex.Infrastructure.GetEventStore/Formatter.cs
  4. 8
      src/Squidex.Infrastructure.GetEventStore/GetEventStore.cs
  5. 4
      src/Squidex.Infrastructure.GetEventStore/GetEventStoreSubscription.cs
  6. 15
      src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj
  7. 1
      src/Squidex.Infrastructure/CQRS/Commands/DefaultDomainObjectRepository.cs
  8. 18
      src/Squidex/Config/Domain/EventStoreModule.cs
  9. 2
      src/Squidex/Squidex.csproj
  10. 8
      src/Squidex/appsettings.json
  11. 7
      tests/Squidex.Infrastructure.Tests/CQRS/Commands/DefaultDomainObjectRepositoryTests.cs
  12. 1
      tests/Squidex.Infrastructure.Tests/CQRS/Events/EventReceiverTests.cs

15
Squidex.Infrastructure.EventStore/Squidex.Infrastructure.EventStore.csproj

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EventStore.ClientAPI.NetCore" Version="4.0.0-alpha-1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup>
</Project>

28
Squidex.sln

@ -56,7 +56,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Domain.Users.MongoD
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Domain.Users.Tests", "tests\Squidex.Domain.Users.Tests\Squidex.Domain.Users.Tests.csproj", "{42184546-E3CB-4D4F-9495-43979B9C63B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Infrastructure.EventStore", "Squidex.Infrastructure.EventStore\Squidex.Infrastructure.EventStore.csproj", "{91D9D992-FA34-49EE-A1D7-DEA5E660424F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Infrastructure.GetEventStore", "src\Squidex.Infrastructure.GetEventStore\Squidex.Infrastructure.GetEventStore.csproj", "{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -268,18 +268,18 @@ Global
{42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x64.Build.0 = Release|Any CPU
{42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x86.ActiveCfg = Release|Any CPU
{42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x86.Build.0 = Release|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|x64.ActiveCfg = Debug|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|x64.Build.0 = Debug|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|x86.ActiveCfg = Debug|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Debug|x86.Build.0 = Debug|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|Any CPU.Build.0 = Release|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|x64.ActiveCfg = Release|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|x64.Build.0 = Release|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|x86.ActiveCfg = Release|Any CPU
{91D9D992-FA34-49EE-A1D7-DEA5E660424F}.Release|x86.Build.0 = Release|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|x64.ActiveCfg = Debug|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|x64.Build.0 = Debug|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|x86.ActiveCfg = Debug|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Debug|x86.Build.0 = Debug|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|Any CPU.Build.0 = Release|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|x64.ActiveCfg = Release|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|x64.Build.0 = Release|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|x86.ActiveCfg = Release|Any CPU
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -307,6 +307,6 @@ Global
{F7771E22-47BD-45C4-A133-FD7F1DE27CA0} = {C0D540F0-9158-4528-BFD8-BEAE6EAE45EA}
{27CF800D-890F-4882-BF05-44EC3233537D} = {C0D540F0-9158-4528-BFD8-BEAE6EAE45EA}
{42184546-E3CB-4D4F-9495-43979B9C63B9} = {C0D540F0-9158-4528-BFD8-BEAE6EAE45EA}
{91D9D992-FA34-49EE-A1D7-DEA5E660424F} = {8CF53B92-5EB1-461D-98F8-70DA9B603FBF}
{EF75E488-1324-4E18-A1BD-D3A05AE67B1F} = {8CF53B92-5EB1-461D-98F8-70DA9B603FBF}
EndGlobalSection
EndGlobal

2
Squidex.Infrastructure.EventStore/Formatter.cs → src/Squidex.Infrastructure.GetEventStore/Formatter.cs

@ -11,7 +11,7 @@ using EventStore.ClientAPI;
using EventData = Squidex.Infrastructure.CQRS.Events.EventData;
using EventStoreData = EventStore.ClientAPI.EventData;
namespace Squidex.Infrastructure.EventStore
namespace Squidex.Infrastructure.GetEventStore
{
public static class Formatter
{

8
Squidex.Infrastructure.EventStore/EventStore.cs → src/Squidex.Infrastructure.GetEventStore/GetEventStore.cs

@ -1,5 +1,5 @@
// ==========================================================================
// EventStore.cs
// GetEventStore.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
@ -17,9 +17,9 @@ using EventData = Squidex.Infrastructure.CQRS.Events.EventData;
// ReSharper disable ConvertIfStatementToSwitchStatement
// ReSharper disable InvertIf
namespace Squidex.Infrastructure.EventStore
namespace Squidex.Infrastructure.GetEventStore
{
public sealed class EventStore : IEventStore, IExternalSystem
public sealed class GetEventStore : IEventStore, IExternalSystem
{
private const int WritePageSize = 500;
private const int ReadPageSize = 500;
@ -27,7 +27,7 @@ namespace Squidex.Infrastructure.EventStore
private readonly string projectionHost;
private readonly string prefix;
public EventStore(IEventStoreConnection connection, string prefix, string projectionHost)
public GetEventStore(IEventStoreConnection connection, string prefix, string projectionHost)
{
Guard.NotNull(connection, nameof(connection));

4
Squidex.Infrastructure.EventStore/EventStoreSubscription.cs → src/Squidex.Infrastructure.GetEventStore/GetEventStoreSubscription.cs

@ -1,5 +1,5 @@
// ==========================================================================
// EventStoreSubscription.cs
// GetEventStoreSubscription.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
@ -18,7 +18,7 @@ using EventStore.ClientAPI.Exceptions;
using EventStore.ClientAPI.Projections;
using Squidex.Infrastructure.CQRS.Events;
namespace Squidex.Infrastructure.EventStore
namespace Squidex.Infrastructure.GetEventStore
{
internal sealed class EventStoreSubscription : IEventSubscription
{

15
src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EventStore.ClientAPI.NetCore" Version="4.0.0-alpha-1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup>
</Project>

1
src/Squidex.Infrastructure/CQRS/Commands/DefaultDomainObjectRepository.cs

@ -9,7 +9,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Squidex.Infrastructure.CQRS.Events;

18
src/Squidex/Config/Domain/EventStoreModule.cs

@ -14,8 +14,8 @@ using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS.Events;
using Squidex.Infrastructure.GetEventStore;
using Squidex.Infrastructure.MongoDb.EventStore;
using EventStoreStore = Squidex.Infrastructure.EventStore.EventStore;
namespace Squidex.Config.Domain
{
@ -79,34 +79,34 @@ namespace Squidex.Config.Domain
.As<IEventStore>()
.SingleInstance();
}
else if (string.Equals(eventStoreType, "EventStore", StringComparison.OrdinalIgnoreCase))
else if (string.Equals(eventStoreType, "GetEventStore", StringComparison.OrdinalIgnoreCase))
{
var configuration = Configuration.GetValue<string>("eventStore:eventStore:configuration");
var configuration = Configuration.GetValue<string>("eventStore:getEventStore:configuration");
if (string.IsNullOrWhiteSpace(configuration))
{
throw new ConfigurationException("Configure EventStore EventStore configuration with 'eventStore:eventStore:configuration'.");
throw new ConfigurationException("Configure GetEventStore EventStore configuration with 'eventStore:getEventStore:configuration'.");
}
var projectionHost = Configuration.GetValue<string>("eventStore:eventStore:projectionHost");
var projectionHost = Configuration.GetValue<string>("eventStore:getEventStore:projectionHost");
if (string.IsNullOrWhiteSpace(projectionHost))
{
throw new ConfigurationException("Configure EventStore EventStore projection host with 'eventStore:eventStore:projectionHost'.");
throw new ConfigurationException("Configure GetEventStore EventStore projection host with 'eventStore:getEventStore:projectionHost'.");
}
var prefix = Configuration.GetValue<string>("eventStore:eventStore:prefix");
var prefix = Configuration.GetValue<string>("eventStore:getEventStore:prefix");
var connection = EventStoreConnection.Create(configuration);
builder.Register(c => new EventStoreStore(connection, prefix, projectionHost))
builder.Register(c => new GetEventStore(connection, prefix, projectionHost))
.As<IExternalSystem>()
.As<IEventStore>()
.SingleInstance();
}
else
{
throw new ConfigurationException($"Unsupported value '{eventStoreType}' for 'eventStore:type', supported: MongoDb, EventStore.");
throw new ConfigurationException($"Unsupported value '{eventStoreType}' for 'eventStore:type', supported: MongoDb, GetEventStore.");
}
}
}

2
src/Squidex/Squidex.csproj

@ -25,11 +25,11 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Squidex.Infrastructure.EventStore\Squidex.Infrastructure.EventStore.csproj" />
<ProjectReference Include="..\Squidex.Domain.Apps.Core\Squidex.Domain.Apps.Core.csproj" />
<ProjectReference Include="..\Squidex.Domain.Apps.Events\Squidex.Domain.Apps.Events.csproj" />
<ProjectReference Include="..\Squidex.Domain.Users.MongoDb\Squidex.Domain.Users.MongoDb.csproj" />
<ProjectReference Include="..\Squidex.Domain.Users\Squidex.Domain.Users.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure.GetEventStore\Squidex.Infrastructure.GetEventStore.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure.GoogleCloud\Squidex.Infrastructure.GoogleCloud.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure.RabbitMq\Squidex.Infrastructure.RabbitMq.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />

8
src/Squidex/appsettings.json

@ -21,15 +21,15 @@
}
},
"eventStore": {
"type": "EventStore",
"type": "GetEventStore",
"mongoDb": {
"configuration": "mongodb://localhost",
"database": "Squidex"
},
"eventStore": {
"getEventStore": {
"configuration": "ConnectTo=tcp://admin:changeit@localhost:1113; HeartBeatTimeout=500",
"projectionHost": "localhost",
"prefix": "squidex"
"projectionHost": "localhost",
"prefix": "squidex"
},
"consume": true
},

7
tests/Squidex.Infrastructure.Tests/CQRS/Commands/DefaultDomainObjectRepositoryTests.cs

@ -8,7 +8,6 @@
using System;
using System.Collections.Generic;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Moq;
using Squidex.Infrastructure.CQRS.Events;
@ -73,7 +72,7 @@ namespace Squidex.Infrastructure.CQRS.Commands
[Fact]
public async Task Should_throw_exception_when_event_store_returns_no_events()
{
eventStore.Setup(x => x.GetEventsAsync(streamName, null)).Returns(Task.FromResult<IReadOnlyList<StoredEvent>>(new List<StoredEvent>()));
eventStore.Setup(x => x.GetEventsAsync(streamName)).Returns(Task.FromResult<IReadOnlyList<StoredEvent>>(new List<StoredEvent>()));
await Assert.ThrowsAsync<DomainObjectNotFoundException>(() => sut.GetByIdAsync<MyDomainObject>(aggregateId));
}
@ -93,7 +92,7 @@ namespace Squidex.Infrastructure.CQRS.Commands
new StoredEvent("1", 1, eventData2)
};
eventStore.Setup(x => x.GetEventsAsync(streamName, null)).Returns(Task.FromResult<IReadOnlyList<StoredEvent>>(events));
eventStore.Setup(x => x.GetEventsAsync(streamName)).Returns(Task.FromResult<IReadOnlyList<StoredEvent>>(events));
eventDataFormatter.Setup(x => x.Parse(eventData1)).Returns(new Envelope<IEvent>(event1));
eventDataFormatter.Setup(x => x.Parse(eventData2)).Returns(new Envelope<IEvent>(event2));
@ -118,7 +117,7 @@ namespace Squidex.Infrastructure.CQRS.Commands
new StoredEvent("1", 1, eventData2)
};
eventStore.Setup(x => x.GetEventsAsync(streamName, null)).Returns(Task.FromResult<IReadOnlyList<StoredEvent>>(events));
eventStore.Setup(x => x.GetEventsAsync(streamName)).Returns(Task.FromResult<IReadOnlyList<StoredEvent>>(events));
eventDataFormatter.Setup(x => x.Parse(eventData1)).Returns(new Envelope<IEvent>(event1));
eventDataFormatter.Setup(x => x.Parse(eventData2)).Returns(new Envelope<IEvent>(event2));

1
tests/Squidex.Infrastructure.Tests/CQRS/Events/EventReceiverTests.cs

@ -91,7 +91,6 @@ namespace Squidex.Infrastructure.CQRS.Events
private readonly Mock<IEventConsumerInfoRepository> eventConsumerInfoRepository = new Mock<IEventConsumerInfoRepository>();
private readonly Mock<IEventConsumer> eventConsumer = new Mock<IEventConsumer>();
private readonly Mock<IEventNotifier> eventNotifier = new Mock<IEventNotifier>();
private readonly Mock<ISemanticLog> log = new Mock<ISemanticLog>();
private readonly Mock<EventDataFormatter> formatter = new Mock<EventDataFormatter>(new TypeNameRegistry(), null);
private readonly EventData eventData1 = new EventData();

Loading…
Cancel
Save