Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus committed Feb 12, 2019
2 parents 1c62759 + 5408256 commit ee11a9d
Show file tree
Hide file tree
Showing 51 changed files with 1,159 additions and 117 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ the [do’s and don’ts](http://docs.geteventflow.net/DosAndDonts.html) and the
* **Async/await first:** Every part of EventFlow is written using async/await.
* **Highly configurable and extendable**
* **Easy to use**
* **No use of threads or background workers making it "web friendly"**
* **No use of threads or background workers**
* **Cancellation:** All methods that does IO work or might delay execution (due to
retries), takes a `CancellationToken` argument to allow you to cancel the operation

Expand Down
24 changes: 23 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
### New in 0.68 (not released yet)
### New in 0.69 (not released yet)

* New: Added configuration option to set the "point of no return" when using
cancellation tokens. After this point in processing, cancellation tokens
are ignored:
`options.Configure(c => c.CancellationBoundary = CancellationBoundary.BeforeCommittingEvents)`
* Fix: Added the schema `dbo` to the `eventdatamodel_list_type` in script
`0002 - Create eventdatamodel_list_type.sql` for `EventFlow.MsSql`.
* New: Added `EventFlowOptions.RunOnStartup<TBootstrap>` extension method to
register `IBootstrap` types that should run on application startup.
* New: Support for async read model updates (`IAmAsyncReadModelFor`).
You can mix and match asynchronous and synchronous updates,
as long as you don't subscribe to the same event in both ways.
* Fix: `LoadAllCommittedEvents` now correctly handles cases where the
`GlobalSequenceNumber` column contains gaps larger than the page size. This bug
lead to incomplete event application when using the `ReadModelPopulator` (see #564).
* Fix: `IResolver.Resolve<T>()` and `IResolver.Resolve(Type)` now throw an
exception for unregistered services when using `EventFlow.DependencyInjection`.
* Minor fix: Fixed stack overflow in `ValidateRegistrations` when decorator
components are co-located together with other components that are registed using
`Add*`-methods

### New in 0.68.3728 (released 2018-12-03)

* Breaking: Changed name of namespace of the projects AspNetCore `EventFlow.Aspnetcore`
to `EventFlow.AspNetCore`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public ServiceProviderResolver(IServiceProvider serviceProvider, IServiceCollect

public T Resolve<T>()
{
return ServiceProvider.GetService<T>();
return ServiceProvider.GetRequiredService<T>();
}

public object Resolve(Type serviceType)
{
return ServiceProvider.GetService(serviceType);
return ServiceProvider.GetRequiredService(serviceType);
}

public IEnumerable<object> ResolveAll(Type serviceType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// 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.EntityFramework.Extensions;
using EventFlow.EntityFramework.Tests.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// 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.EntityFramework.Extensions;
using EventFlow.EntityFramework.Tests.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// 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.EntityFramework.Extensions;
using EventFlow.EntityFramework.Tests.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// 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.EntityFramework.Extensions;
using EventFlow.EntityFramework.Tests.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ public async Task<AllCommittedEventsPage> LoadAllCommittedEvents(GlobalPosition
var startPosition = globalPosition.IsStart
? 0
: long.Parse(globalPosition.Value);
var endPosition = startPosition + pageSize;

using (var context = _contextProvider.CreateContext())
{
var entities = await context
.Set<EventEntity>()
.Where(e => e.GlobalSequenceNumber >= startPosition
&& e.GlobalSequenceNumber <= endPosition)
.OrderBy(e => e.GlobalSequenceNumber)
.Where(e => e.GlobalSequenceNumber >= startPosition)
.Take(pageSize)
.ToListAsync(cancellationToken)
.ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System;
using System.Threading.Tasks;
using EventFlow.Configuration;
using EventFlow.EventStores.EventStore.Extensions;
using EventFlow.Extensions;
Expand Down Expand Up @@ -57,5 +58,12 @@ protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowO

return resolver;
}

public override Task LoadAllEventsAsyncFindsEventsAfterLargeGaps()
{
// Need to reset DB in order to make this test work.

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.Threading.Tasks;
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
{
Expand Down
29 changes: 26 additions & 3 deletions Source/EventFlow.MongoDB/EventStore/MongoDbEventPersistence.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
using System;
// The MIT License (MIT)
//
// Copyright (c) 2015-2019 Rasmus Mikkelsen
// Copyright (c) 2015-2019 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 System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -32,10 +55,10 @@ public async Task<AllCommittedEventsPage> LoadAllCommittedEvents(GlobalPosition
long startPosition = globalPosition.IsStart
? 0
: long.Parse(globalPosition.Value);
long endPosition = startPosition + pageSize;

List<MongoDbEventDataModel> eventDataModels = await MongoDbEventStoreCollection
.Find(model => model._id >= startPosition && model._id <= endPosition)
.Find(model => model._id >= startPosition)
.Limit(pageSize)
.ToListAsync(cancellationToken)
.ConfigureAwait(continueOnCapturedContext: false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// 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.Extensions;
using EventFlow.MsSql.EventStores;
Expand Down
15 changes: 7 additions & 8 deletions Source/EventFlow.MsSql/EventStores/MsSqlEventPersistence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,23 @@ public async Task<AllCommittedEventsPage> LoadAllCommittedEvents(
var startPosition = globalPosition.IsStart
? 0
: long.Parse(globalPosition.Value);
var endPosition = startPosition + pageSize;

const string sql = @"
SELECT
SELECT TOP(@pageSize)
GlobalSequenceNumber, BatchId, AggregateId, AggregateName, Data, Metadata, AggregateSequenceNumber
FROM EventFlow
WHERE
GlobalSequenceNumber >= @FromId AND GlobalSequenceNumber <= @ToId
GlobalSequenceNumber >= @startPosition
ORDER BY
GlobalSequenceNumber ASC";
var eventDataModels = await _connection.QueryAsync<EventDataModel>(
Label.Named("mssql-fetch-events"),
cancellationToken,
sql,
new
cancellationToken,
sql,
new
{
FromId = startPosition,
ToId = endPosition,
startPosition,
pageSize
})
.ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
IF NOT EXISTS (SELECT * FROM SYS.TYPES WHERE is_table_type = 1 AND name = 'eventdatamodel_list_type')
BEGIN
CREATE TYPE eventdatamodel_list_type AS TABLE
CREATE TYPE dbo.eventdatamodel_list_type AS TABLE
(
[AggregateId] [nvarchar](255) NOT NULL,
[AggregateName] [nvarchar](255) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// 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.Extensions;
using EventFlow.PostgreSql.Connections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,24 @@ public async Task<AllCommittedEventsPage> LoadAllCommittedEvents(
var startPosition = globalPosition.IsStart
? 0
: long.Parse(globalPosition.Value);
var endPosition = startPosition + pageSize;

const string sql = @"
SELECT
GlobalSequenceNumber, BatchId, AggregateId, AggregateName, Data, Metadata, AggregateSequenceNumber
FROM EventFlow
WHERE
GlobalSequenceNumber >= @FromId AND GlobalSequenceNumber <= @ToId
GlobalSequenceNumber >= @startPosition
ORDER BY
GlobalSequenceNumber ASC;";
GlobalSequenceNumber ASC
LIMIT @pageSize;";
var eventDataModels = await _connection.QueryAsync<EventDataModel>(
Label.Named("postgresql-fetch-events"),
cancellationToken,
sql,
new
Label.Named("postgresql-fetch-events"),
cancellationToken,
sql,
new
{
FromId = startPosition,
ToId = endPosition,
startPosition,
pageSize
})
.ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using EventFlow.Configuration;
using EventFlow.Core;
using EventFlow.Extensions;
Expand Down
18 changes: 9 additions & 9 deletions Source/EventFlow.SQLite/EventStores/SQLiteEventPersistence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,24 @@ public async Task<AllCommittedEventsPage> LoadAllCommittedEvents(
var startPosition = globalPosition.IsStart
? 0
: long.Parse(globalPosition.Value);
var endPosition = startPosition + pageSize;

const string sql = @"
SELECT
GlobalSequenceNumber, BatchId, AggregateId, AggregateName, Data, Metadata, AggregateSequenceNumber
FROM EventFlow
WHERE
GlobalSequenceNumber >= @FromId AND GlobalSequenceNumber <= @ToId
GlobalSequenceNumber >= @startPosition
ORDER BY
GlobalSequenceNumber ASC";
GlobalSequenceNumber ASC
LIMIT @pageSize";
var eventDataModels = await _connection.QueryAsync<EventDataModel>(
Label.Named("sqlite-fetch-events"),
cancellationToken,
sql,
new
Label.Named("sqlite-fetch-events"),
cancellationToken,
sql,
new
{
FromId = startPosition,
ToId = endPosition,
startPosition,
pageSize
})
.ConfigureAwait(false);

Expand Down
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.Threading;
using System.Threading.Tasks;
using EventFlow.Aggregates;
using EventFlow.Aggregates.ExecutionResults;
using EventFlow.Commands;
using EventFlow.Core;

namespace EventFlow.TestHelpers.Aggregates.Decorators
{
/// <summary>
/// Caused StackOverflowException when colocated with command handlers and using options.AddDefaults().
/// </summary>
/// <seealso cref="http://github.com/eventflow/EventFlow/issues/523"/>
public class SomeCommandHandlerDecorator<TAggregate, TIdentity, TResult, TCommand> :
CommandHandler<TAggregate, TIdentity, TResult, TCommand>
where TAggregate : IAggregateRoot<TIdentity>
where TIdentity : IIdentity
where TResult : IExecutionResult
where TCommand : ICommand<TAggregate, TIdentity, TResult>
{
public SomeCommandHandlerDecorator(ICommandHandler<TAggregate, TIdentity, TResult, TCommand> inner)
{
}

public override Task<TResult> ExecuteCommandAsync(TAggregate aggregate, TCommand command, CancellationToken cancellationToken)
{
throw new System.NotImplementedException();
}
}
}
Loading

0 comments on commit ee11a9d

Please sign in to comment.