Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasmus Mikkelsen committed Dec 3, 2018
2 parents 4ff68c1 + c852b66 commit 1c62759
Show file tree
Hide file tree
Showing 44 changed files with 1,658 additions and 319 deletions.
13 changes: 13 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ If you think your name is missing from the list, create a pull-request.

* Created the current logo of EventFlow

### [Edward Wilson](https://github.com/edwardwilson)

* Original MongoDB author

### [Frank Ebersoll](https://github.com/frankebersoll)

* Created following packages
Expand All @@ -26,12 +30,17 @@ If you think your name is missing from the list, create a pull-request.

* PostgreSQL implementation
* EntityFramework implementation
* Build and integration test improvements

### [Jaco Coetzee](https://github.com/JC008)

* Several key contributions and bug fixes
* Donated Navicat Essentials for SQLite

### [janfeyen](https://github.com/janfeyen)

* Key MongoDB contributions

### [rmess](https://github.com/rmess)

* PostgreSQL implementation
Expand All @@ -40,3 +49,7 @@ If you think your name is missing from the list, create a pull-request.

* Original creator and author of EventFlow

### [Willem Peters](https://github.com/wgtmpeters)

* MongoDB cleanup and move to main repository

564 changes: 289 additions & 275 deletions EventFlow.sln

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
### New in 0.67 (not released yet)
### New in 0.68 (not released yet)

* Breaking: Changed name of namespace of the projects AspNetCore `EventFlow.Aspnetcore`
to `EventFlow.AspNetCore`
* Fix: Ignore multiple loads of the same saga

### New in 0.67.3697 (released 2018-10-14)

* New: Expose `Lifetime.Scoped` through the EventFLow service registration
interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using System;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using EventFlow.Aspnetcore.Middlewares;
using EventFlow.AspNetCore.Middlewares;
using EventFlow.AspNetCore.Extensions;
using EventFlow.Autofac.Extensions;
using EventFlow.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
using EventFlow.EventStores;
using Microsoft.AspNetCore.Http;

namespace EventFlow.Aspnetcore.MetadataProviders
namespace EventFlow.AspNetCore.MetadataProviders
{
public class AddRequestHeadersMetadataProvider : IMetadataProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;

namespace EventFlow.Aspnetcore.MetadataProviders
namespace EventFlow.AspNetCore.MetadataProviders
{
public class AddUserHostAddressMetadataProvider : IMetadataProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
using EventFlow.Logs;
using Microsoft.AspNetCore.Http;

namespace EventFlow.Aspnetcore.Middlewares
namespace EventFlow.AspNetCore.Middlewares
{
public class CommandPublishMiddleware
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
using EventFlow.TestHelpers.Suites;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using NUnit.Framework;

namespace EventFlow.DependencyInjection.Tests.UnitTests
Expand All @@ -38,41 +37,6 @@ public class ServiceCollectionServiceRegistrationTests : TestSuiteForServiceRegi
{
private ServiceCollection _serviceCollection;

[Test]
public void ValidateRegistrationsShouldDispose()
{
// Arrange
var service = new Mock<I>();
var createdCount = 0;
Sut.Register(_ =>
{
createdCount++;
return service.Object;
});

// Act and Assert
using (var resolver = Sut.CreateResolver(true))
{
createdCount.Should().Be(1);
service.Verify(m => m.Dispose(), Times.Once);

var resolvedService = resolver.Resolve<I>();
createdCount.Should().Be(2);
resolvedService.Should().BeSameAs(service.Object);

using (var scopedResolver = resolver.BeginScope())
{
var nestedResolvedService = scopedResolver.Resolve<I>();
createdCount.Should().Be(3);
nestedResolvedService.Should().BeSameAs(service.Object);
}

service.Verify(m => m.Dispose(), Times.Exactly(2));
}

service.Verify(m => m.Dispose(), Times.Exactly(3));
}

[Test]
public void AddEventFlowRegistersEventFlowInServiceCollection()
{
Expand Down
17 changes: 17 additions & 0 deletions Source/EventFlow.MongoDB.Tests/EventFlow.MongoDB.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Common.props" />
<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.7.2" />
<PackageReference Include="Mongo2Go" Version="2.2.8" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EventFlow.MongoDB\EventFlow.MongoDB.csproj" />
<ProjectReference Include="..\EventFlow.TestHelpers\EventFlow.TestHelpers.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using EventFlow.Configuration;
using EventFlow.TestHelpers;
using EventFlow.TestHelpers.Suites;
using EventFlow.Extensions;
using EventFlow.MongoDB.EventStore;
using EventFlow.MongoDB.Extensions;
using EventFlow.MongoDB.ValueObjects;
using NUnit.Framework;
using Mongo2Go;
using MongoDB.Driver;

namespace EventFlow.MongoDB.Tests.IntegrationTests.EventStores
{
[Category(Categories.Integration)]
[TestFixture]
[NUnit.Framework.Timeout(30000)]
public class MongoDbEventStoreTests : TestSuiteForEventStore
{
private MongoDbRunner _runner;

protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
{
_runner = MongoDbRunner.Start();
var resolver = eventFlowOptions
.ConfigureMongoDb(_runner.ConnectionString, "eventflow")
.UseMongoDbEventStore()
.CreateResolver();
var eventPersistenceInitializer = resolver.Resolve<IMongoDbEventPersistenceInitializer>();
eventPersistenceInitializer.Initialize();

return resolver;
}

[TearDown]
public void TearDown()
{
_runner.Dispose();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2018 Rasmus Mikkelsen
// Copyright (c) 2015-2018 eBay Software Foundation
// https://github.com/eventflow/EventFlow
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System;
using EventFlow.Configuration;
using EventFlow.Extensions;
using EventFlow.MongoDB.Extensions;
using EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.QueryHandlers;
using EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.ReadModels;
using EventFlow.MongoDB.ValueObjects;
using EventFlow.TestHelpers;
using EventFlow.TestHelpers.Aggregates.Entities;
using EventFlow.TestHelpers.Suites;
using Mongo2Go;
using MongoDB.Driver;
using NUnit.Framework;

namespace EventFlow.MongoDB.Tests.IntegrationTests.ReadStores
{
[Category(Categories.Integration)]
[TestFixture]
[NUnit.Framework.Timeout(30000)]
public class MongoDbReadModelStoreTests : TestSuiteForReadModelStore
{
protected override Type ReadModelType { get; } = typeof(MongoDbThingyReadModel);

private MongoDbRunner _runner;

protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
{
_runner = MongoDbRunner.Start();

var resolver = eventFlowOptions
.RegisterServices(sr => { sr.RegisterType(typeof(ThingyMessageLocator)); })
.ConfigureMongoDb(_runner.ConnectionString, "eventflow")
.UseMongoDbReadModel<MongoDbThingyReadModel>()
.UseMongoDbReadModel<MongoDbThingyMessageReadModel, ThingyMessageLocator>()
.AddQueryHandlers(
typeof(MongoDbThingyGetQueryHandler),
typeof(MongoDbThingyGetVersionQueryHandler),
typeof(MongoDbThingyGetMessagesQueryHandler))
.CreateResolver();

return resolver;
}


[TearDown]
public void TearDown()
{
_runner.Dispose();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2018 Rasmus Mikkelsen
// Copyright (c) 2015-2018 eBay Software Foundation
// https://github.com/eventflow/EventFlow
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using EventFlow.MongoDB.ReadStores;
using EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.ReadModels;
using EventFlow.Queries;
using EventFlow.TestHelpers.Aggregates.Entities;
using EventFlow.TestHelpers.Aggregates.Queries;
using MongoDB.Driver;

namespace EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.QueryHandlers
{
public class MongoDbThingyGetMessagesQueryHandler : IQueryHandler<ThingyGetMessagesQuery, IReadOnlyCollection<ThingyMessage>>
{
private readonly IMongoDbReadModelStore<MongoDbThingyMessageReadModel> _readStore;

public MongoDbThingyGetMessagesQueryHandler(
IMongoDbReadModelStore<MongoDbThingyMessageReadModel> mongeReadStore)
{
_readStore = mongeReadStore;
}

public async Task<IReadOnlyCollection<ThingyMessage>> ExecuteQueryAsync(ThingyGetMessagesQuery query, CancellationToken cancellationToken)
{
var thingyId = query.ThingyId.ToString();
var asyncCursor = await _readStore.FindAsync(f => string.Equals(f.ThingyId, thingyId), cancellationToken: cancellationToken).ConfigureAwait(false);
var thingyMessageReadModels = await asyncCursor.ToListAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
return thingyMessageReadModels.Select(b => b.ToThingyMessage()).ToList();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2018 Rasmus Mikkelsen
// Copyright (c) 2015-2018 eBay Software Foundation
// https://github.com/eventflow/EventFlow
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using EventFlow.MongoDB.ReadStores;
using EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.ReadModels;
using EventFlow.Queries;
using EventFlow.TestHelpers.Aggregates;
using EventFlow.TestHelpers.Aggregates.Queries;
using MongoDB.Driver;

namespace EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.QueryHandlers
{
public class MongoDbThingyGetQueryHandler : IQueryHandler<ThingyGetQuery, Thingy>
{
private readonly IMongoDbReadModelStore<MongoDbThingyReadModel> _readStore;
public MongoDbThingyGetQueryHandler(
IMongoDbReadModelStore<MongoDbThingyReadModel> mongeReadStore)
{
_readStore = mongeReadStore;
}

public async Task<Thingy> ExecuteQueryAsync(ThingyGetQuery query, CancellationToken cancellationToken)
{
var thingyId = query.ThingyId.ToString();
var asyncCursor = await _readStore.FindAsync(f => string.Equals(f.Id, thingyId), cancellationToken: cancellationToken).ConfigureAwait(false);
var thingyReadModel = await asyncCursor.FirstOrDefaultAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
return thingyReadModel?.ToThingy();
}
}
}
Loading

0 comments on commit 1c62759

Please sign in to comment.