Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus committed Oct 14, 2018
2 parents 226e05e + 4a6d0dc commit 4ff68c1
Show file tree
Hide file tree
Showing 39 changed files with 450 additions and 222 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ the [do’s and don’ts](http://docs.geteventflow.net/DosAndDonts.html) and the
_in-progress_, but should provide inspiration on how to use EventFlow on a
larger scale. If you have ideas and/or comments, create a pull request or
an issue

#### External Examples

* **[Racetimes:](https://github.com/dennisfabri/Eventflow.Example.Racetimes)**
Shows some features of EventFlow that are not covered in the
[complete example](#complete-example). It features entities, a read model for
an entity, delete on read models, specifications and snapshots.

### Overview

Expand Down
31 changes: 25 additions & 6 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
### New in 0.66 (not released yet)

* **Critical fix:** - fix issue where the process using EventFlow could hang using 100% CPU due to unsynchronized Dictionary access, See #541.

### New in 0.65.3664 (eleased 2018-09-22)

### New in 0.67 (not released yet)

* New: Expose `Lifetime.Scoped` through the EventFLow service registration
interface
* New: Upgrade NEST version to 6.1.0 and Hangfire.Core to 1.6.20
Now Elasticsearch provide one index per document. If `ElasticsearchTypeAttribute`
is used the index is map with the Name value as an alias.
When `ElasticsearchReadModelStore` delete all documents, it will delete
all indexes linked to the alias.
* Fix: Internal IoC (remember its just for testing) now correctly invokes
`IDisposable.Dispose()` on scope and container dispose

### New in 0.66.3673 (released 2018-09-30)

* **Critical fix:** - fix issue where the process using EventFlow could hang using
100% CPU due to unsynchronized Dictionary access, See #541.

### New in 0.65.3664 (released 2018-09-22)

* New: Entity Framework Core support in the form of the new `EventFlow.EntityFramework` NuGet
package. It has been tested with the following stacks.
- EF Core In-Memory Database Provider
- SQLite
- SQL Server
- PostgreSQL
* Minor: Performance improvement of storing events for `EventFlow.PostgreSql`

### New in 0.64.3598 (released 2018-08-24)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
using EventFlow.Aspnetcore.Middlewares;
using EventFlow.AspNetCore.Extensions;
using EventFlow.Autofac.Extensions;
using EventFlow.Configuration;
using EventFlow.Extensions;
using EventFlow.TestHelpers;
using EventFlow.TestHelpers.Aggregates.Queries;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -47,7 +49,8 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
var container = EventFlowOptions.New
.UseAutofacContainerBuilder(containerBuilder)
.AddDefaults(EventFlowTestHelpers.Assembly)
.AddAspNetCoreMetadataProviders();
.RegisterServices(sr => sr.Register<IScopedContext, ScopedContext>(Lifetime.Scoped))
.AddAspNetCoreMetadataProviders();


containerBuilder.Populate(services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@
// 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.Threading.Tasks;
using Autofac;
using EventFlow.Autofac.Extensions;
using EventFlow.Configuration;
using EventFlow.Extensions;
using EventFlow.TestHelpers;
using EventFlow.TestHelpers.Aggregates.Queries;
using EventFlow.TestHelpers.Suites;
using NUnit.Framework;

Expand All @@ -38,24 +35,14 @@ public class AutofacServiceRegistrationIntegrationTests : IntegrationTestSuiteFo
{
protected override IEventFlowOptions Options(IEventFlowOptions eventFlowOptions)
{
var builder = new ContainerBuilder();
builder.RegisterType<DbContext>().As<IDbContext>().InstancePerLifetimeScope();

return base.Options(eventFlowOptions
.UseAutofacContainerBuilder(builder))
.AddQueryHandler<DbContextQueryHandler, DbContextQuery, string>();
.UseAutofacContainerBuilder(new ContainerBuilder()));
}

protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
{
return eventFlowOptions
.CreateResolver();
}

[Test]
public override Task QueryingUsesScopedDbContext()
{
return base.QueryingUsesScopedDbContext();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,16 @@
using EventFlow.Configuration;
using EventFlow.TestHelpers;
using EventFlow.TestHelpers.Suites;
using FluentAssertions;
using Moq;
using NUnit.Framework;

namespace EventFlow.Autofac.Tests.UnitTests
{
[Category(Categories.Unit)]
public class AutofacServiceRegistrationTests : TestSuiteForServiceRegistration
{
[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));
}

protected override IServiceRegistration CreateSut()
{
return new AutofacServiceRegistration();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public AutofacServiceRegistration(ContainerBuilder containerBuilder)
{
registration.SingleInstance();
}
if (lifetime == Lifetime.Scoped)
{
registration.InstancePerLifetimeScope();
}

var serviceRegistration = _containerBuilder
.Register<TService>(c => c.Resolve<TImplementation>())
Expand Down Expand Up @@ -91,6 +95,10 @@ public AutofacServiceRegistration(ContainerBuilder containerBuilder)
{
registration.SingleInstance();
}
if (lifetime == Lifetime.Scoped)
{
registration.InstancePerLifetimeScope();
}
if (keepDefault)
{
registration.PreserveExistingDefaults();
Expand All @@ -115,6 +123,10 @@ public AutofacServiceRegistration(ContainerBuilder containerBuilder)
{
registration.SingleInstance();
}
if (lifetime == Lifetime.Scoped)
{
registration.InstancePerLifetimeScope();
}
if (keepDefault)
{
registration.PreserveExistingDefaults();
Expand All @@ -137,6 +149,10 @@ public AutofacServiceRegistration(ContainerBuilder containerBuilder)
{
registration.SingleInstance();
}
if (lifetime == Lifetime.Scoped)
{
registration.InstancePerLifetimeScope();
}
if (keepDefault)
{
registration.PreserveExistingDefaults();
Expand All @@ -155,6 +171,10 @@ public AutofacServiceRegistration(ContainerBuilder containerBuilder)
{
registration.SingleInstance();
}
if (lifetime == Lifetime.Scoped)
{
registration.InstancePerLifetimeScope();
}
}

public void RegisterIfNotRegistered<TService, TImplementation>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
// 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.Threading.Tasks;
using EventFlow.Configuration;
using EventFlow.DependencyInjection.Extensions;
using EventFlow.Extensions;
using EventFlow.TestHelpers;
using EventFlow.TestHelpers.Aggregates.Queries;
using EventFlow.TestHelpers.Suites;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
Expand All @@ -38,25 +35,14 @@ public class ServiceCollectionServiceRegistrationIntegrationTests : IntegrationT
{
protected override IEventFlowOptions Options(IEventFlowOptions eventFlowOptions)
{
var serviceCollection = new ServiceCollection();

serviceCollection.AddScoped<IDbContext, DbContext>();

return base.Options(eventFlowOptions
.UseServiceCollection(serviceCollection))
.AddQueryHandler<DbContextQueryHandler, DbContextQuery, string>();
.UseServiceCollection(new ServiceCollection()));
}

protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
{
return eventFlowOptions
.CreateResolver();
}

[Test]
public override Task QueryingUsesScopedDbContext()
{
return base.QueryingUsesScopedDbContext();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ private ServiceLifetime GetLifetime(Lifetime lifetime)
return ServiceLifetime.Transient;
case Lifetime.Singleton:
return ServiceLifetime.Singleton;
case Lifetime.Scoped:
return ServiceLifetime.Scoped;
default:
throw new ArgumentOutOfRangeException(nameof(lifetime), lifetime, null);
}
Expand Down
Loading

0 comments on commit 4ff68c1

Please sign in to comment.