Skip to content

Commit 4ff68c1

Browse files
committed
Merge branch 'develop'
2 parents 226e05e + 4a6d0dc commit 4ff68c1

39 files changed

Lines changed: 450 additions & 222 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ the [do’s and don’ts](http://docs.geteventflow.net/DosAndDonts.html) and the
5959
_in-progress_, but should provide inspiration on how to use EventFlow on a
6060
larger scale. If you have ideas and/or comments, create a pull request or
6161
an issue
62+
63+
#### External Examples
64+
65+
* **[Racetimes:](https://github.com/dennisfabri/Eventflow.Example.Racetimes)**
66+
Shows some features of EventFlow that are not covered in the
67+
[complete example](#complete-example). It features entities, a read model for
68+
an entity, delete on read models, specifications and snapshots.
6269

6370
### Overview
6471

RELEASE_NOTES.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1-
### New in 0.66 (not released yet)
2-
3-
* **Critical fix:** - fix issue where the process using EventFlow could hang using 100% CPU due to unsynchronized Dictionary access, See #541.
4-
5-
### New in 0.65.3664 (eleased 2018-09-22)
6-
1+
### New in 0.67 (not released yet)
2+
3+
* New: Expose `Lifetime.Scoped` through the EventFLow service registration
4+
interface
5+
* New: Upgrade NEST version to 6.1.0 and Hangfire.Core to 1.6.20
6+
Now Elasticsearch provide one index per document. If `ElasticsearchTypeAttribute`
7+
is used the index is map with the Name value as an alias.
8+
When `ElasticsearchReadModelStore` delete all documents, it will delete
9+
all indexes linked to the alias.
10+
* Fix: Internal IoC (remember its just for testing) now correctly invokes
11+
`IDisposable.Dispose()` on scope and container dispose
12+
13+
### New in 0.66.3673 (released 2018-09-30)
14+
15+
* **Critical fix:** - fix issue where the process using EventFlow could hang using
16+
100% CPU due to unsynchronized Dictionary access, See #541.
17+
18+
### New in 0.65.3664 (released 2018-09-22)
19+
20+
* New: Entity Framework Core support in the form of the new `EventFlow.EntityFramework` NuGet
21+
package. It has been tested with the following stacks.
22+
- EF Core In-Memory Database Provider
23+
- SQLite
24+
- SQL Server
25+
- PostgreSQL
726
* Minor: Performance improvement of storing events for `EventFlow.PostgreSql`
827

928
### New in 0.64.3598 (released 2018-08-24)

Source/EventFlow.AspNetCore.Tests/IntegrationTests/Site/Startup.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
using EventFlow.Aspnetcore.Middlewares;
2828
using EventFlow.AspNetCore.Extensions;
2929
using EventFlow.Autofac.Extensions;
30+
using EventFlow.Configuration;
3031
using EventFlow.Extensions;
3132
using EventFlow.TestHelpers;
33+
using EventFlow.TestHelpers.Aggregates.Queries;
3234
using Microsoft.AspNetCore.Builder;
3335
using Microsoft.AspNetCore.Hosting;
3436
using Microsoft.Extensions.DependencyInjection;
@@ -47,7 +49,8 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
4749
var container = EventFlowOptions.New
4850
.UseAutofacContainerBuilder(containerBuilder)
4951
.AddDefaults(EventFlowTestHelpers.Assembly)
50-
.AddAspNetCoreMetadataProviders();
52+
.RegisterServices(sr => sr.Register<IScopedContext, ScopedContext>(Lifetime.Scoped))
53+
.AddAspNetCoreMetadataProviders();
5154

5255

5356
containerBuilder.Populate(services);

Source/EventFlow.Autofac.Tests/IntegrationTests/AutofacServiceRegistrationIntegrationTests.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@
2121
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2222
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323

24-
using System.Threading.Tasks;
2524
using Autofac;
2625
using EventFlow.Autofac.Extensions;
2726
using EventFlow.Configuration;
28-
using EventFlow.Extensions;
2927
using EventFlow.TestHelpers;
30-
using EventFlow.TestHelpers.Aggregates.Queries;
3128
using EventFlow.TestHelpers.Suites;
3229
using NUnit.Framework;
3330

@@ -38,24 +35,14 @@ public class AutofacServiceRegistrationIntegrationTests : IntegrationTestSuiteFo
3835
{
3936
protected override IEventFlowOptions Options(IEventFlowOptions eventFlowOptions)
4037
{
41-
var builder = new ContainerBuilder();
42-
builder.RegisterType<DbContext>().As<IDbContext>().InstancePerLifetimeScope();
43-
4438
return base.Options(eventFlowOptions
45-
.UseAutofacContainerBuilder(builder))
46-
.AddQueryHandler<DbContextQueryHandler, DbContextQuery, string>();
39+
.UseAutofacContainerBuilder(new ContainerBuilder()));
4740
}
4841

4942
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
5043
{
5144
return eventFlowOptions
5245
.CreateResolver();
5346
}
54-
55-
[Test]
56-
public override Task QueryingUsesScopedDbContext()
57-
{
58-
return base.QueryingUsesScopedDbContext();
59-
}
6047
}
6148
}

Source/EventFlow.Autofac.Tests/UnitTests/AutofacServiceRegistrationTests.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,52 +25,16 @@
2525
using EventFlow.Configuration;
2626
using EventFlow.TestHelpers;
2727
using EventFlow.TestHelpers.Suites;
28-
using FluentAssertions;
29-
using Moq;
3028
using NUnit.Framework;
3129

3230
namespace EventFlow.Autofac.Tests.UnitTests
3331
{
3432
[Category(Categories.Unit)]
3533
public class AutofacServiceRegistrationTests : TestSuiteForServiceRegistration
3634
{
37-
[Test]
38-
public void ValidateRegistrationsShouldDispose()
39-
{
40-
// Arrange
41-
var service = new Mock<I>();
42-
var createdCount = 0;
43-
Sut.Register(_ =>
44-
{
45-
createdCount++;
46-
return service.Object;
47-
});
48-
49-
// Act and Assert
50-
using (var resolver = Sut.CreateResolver(true))
51-
{
52-
createdCount.Should().Be(1);
53-
service.Verify(m => m.Dispose(), Times.Once);
54-
55-
var resolvedService = resolver.Resolve<I>();
56-
createdCount.Should().Be(2);
57-
resolvedService.Should().BeSameAs(service.Object);
58-
59-
using (var scopedResolver = resolver.BeginScope())
60-
{
61-
var nestedResolvedService = scopedResolver.Resolve<I>();
62-
createdCount.Should().Be(3);
63-
nestedResolvedService.Should().BeSameAs(service.Object);
64-
}
65-
service.Verify(m => m.Dispose(), Times.Exactly(2));
66-
}
67-
68-
service.Verify(m => m.Dispose(), Times.Exactly(3));
69-
}
70-
7135
protected override IServiceRegistration CreateSut()
7236
{
7337
return new AutofacServiceRegistration();
7438
}
7539
}
76-
}
40+
}

Source/EventFlow.Autofac/Registrations/AutofacServiceRegistration.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public void Register<TService, TImplementation>(
5858
{
5959
registration.SingleInstance();
6060
}
61+
if (lifetime == Lifetime.Scoped)
62+
{
63+
registration.InstancePerLifetimeScope();
64+
}
6165

6266
var serviceRegistration = _containerBuilder
6367
.Register<TService>(c => c.Resolve<TImplementation>())
@@ -91,6 +95,10 @@ public void Register<TService>(
9195
{
9296
registration.SingleInstance();
9397
}
98+
if (lifetime == Lifetime.Scoped)
99+
{
100+
registration.InstancePerLifetimeScope();
101+
}
94102
if (keepDefault)
95103
{
96104
registration.PreserveExistingDefaults();
@@ -115,6 +123,10 @@ public void Register(
115123
{
116124
registration.SingleInstance();
117125
}
126+
if (lifetime == Lifetime.Scoped)
127+
{
128+
registration.InstancePerLifetimeScope();
129+
}
118130
if (keepDefault)
119131
{
120132
registration.PreserveExistingDefaults();
@@ -137,6 +149,10 @@ public void RegisterType(
137149
{
138150
registration.SingleInstance();
139151
}
152+
if (lifetime == Lifetime.Scoped)
153+
{
154+
registration.InstancePerLifetimeScope();
155+
}
140156
if (keepDefault)
141157
{
142158
registration.PreserveExistingDefaults();
@@ -155,6 +171,10 @@ public void RegisterGeneric(
155171
{
156172
registration.SingleInstance();
157173
}
174+
if (lifetime == Lifetime.Scoped)
175+
{
176+
registration.InstancePerLifetimeScope();
177+
}
158178
}
159179

160180
public void RegisterIfNotRegistered<TService, TImplementation>(

Source/EventFlow.DependencyInjection.Tests/IntegrationTests/ServiceCollectionServiceRegistrationIntegrationTests.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2222
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323

24-
using System.Threading.Tasks;
2524
using EventFlow.Configuration;
2625
using EventFlow.DependencyInjection.Extensions;
27-
using EventFlow.Extensions;
2826
using EventFlow.TestHelpers;
29-
using EventFlow.TestHelpers.Aggregates.Queries;
3027
using EventFlow.TestHelpers.Suites;
3128
using Microsoft.Extensions.DependencyInjection;
3229
using NUnit.Framework;
@@ -38,25 +35,14 @@ public class ServiceCollectionServiceRegistrationIntegrationTests : IntegrationT
3835
{
3936
protected override IEventFlowOptions Options(IEventFlowOptions eventFlowOptions)
4037
{
41-
var serviceCollection = new ServiceCollection();
42-
43-
serviceCollection.AddScoped<IDbContext, DbContext>();
44-
4538
return base.Options(eventFlowOptions
46-
.UseServiceCollection(serviceCollection))
47-
.AddQueryHandler<DbContextQueryHandler, DbContextQuery, string>();
39+
.UseServiceCollection(new ServiceCollection()));
4840
}
4941

5042
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
5143
{
5244
return eventFlowOptions
5345
.CreateResolver();
5446
}
55-
56-
[Test]
57-
public override Task QueryingUsesScopedDbContext()
58-
{
59-
return base.QueryingUsesScopedDbContext();
60-
}
6147
}
6248
}

Source/EventFlow.DependencyInjection/Registrations/ServiceCollectionServiceRegistration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ private ServiceLifetime GetLifetime(Lifetime lifetime)
154154
return ServiceLifetime.Transient;
155155
case Lifetime.Singleton:
156156
return ServiceLifetime.Singleton;
157+
case Lifetime.Scoped:
158+
return ServiceLifetime.Scoped;
157159
default:
158160
throw new ArgumentOutOfRangeException(nameof(lifetime), lifetime, null);
159161
}

0 commit comments

Comments
 (0)