Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus committed Apr 5, 2016
2 parents f525958 + 970d6f9 commit 7556dad
Show file tree
Hide file tree
Showing 40 changed files with 888 additions and 280 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ EventFlow _is_ currently used in production environments and performs very well
but it need to mature before key APIs are stable.

EventFlow is greatly opinionated, but its possible to create new implementations
for almost every part of EventFlow by registering a different implementation of a
a interface.
for almost every part of EventFlow by registering a different implementation of
an interface.

## Useful articles related to EventFlow and DDD

Expand Down
22 changes: 21 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
### New in 0.27 (not released yet)
### New in 0.28 (not released yet)

* **Critical fix:** `OptimisticConcurrencyRetryStrategy` now correctly only
states that `OptimisticConcurrencyException` should be retried. Before
_ALL_ exceptions from the event stores were retried, not only the transient!
If you have inadvertently become dependent on this bug, then implement your
own `IOptimisticConcurrencyRetryStrategy` that has the old behavior
* Fixed: `OptimisticConcurrencyRetryStrategy` has a off-by-one error that caused
it to retry one less that it actually should
* Fixed: Prevent `abstract ICommandHandler<,,,>` from being registered in
`EventFlowOptionsCommandHandlerExtensions.AddCommandHandlers(...)`
* Fixed: Prevent `abstract IEventUpgrader<,>` from being registered in
`EventFlowOptionsEventUpgradersExtensions.AddEventUpgraders(...)`
* Fixed: Prevent `abstract IMetadataProvider` from being registered in
`EventFlowOptionsMetadataProvidersExtensions.AddMetadataProviders(...)`
* Fixed: Prevent `abstract IQueryHandler<,>` from being registered in
`EventFlowOptionsQueriesExtensions.AddQueryHandlers(...)`
* Fixed: Prevent `abstract ISubscribeSynchronousTo<,,>` from being registered in
`EventFlowOptionsSubscriberExtensions.AddSubscribers(...)`

### New in 0.27.1765 (released 2016-02-25)

* New: Configure Hangfire job display names by implementing
`IJobDisplayNameBuilder`. The default implementation uses job description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
namespace EventFlow.Autofac.Tests.UnitTests.Aggregates
{
[TestFixture]
[Category(Categories.Scenario)]
[Category(Categories.Integration)]
public class AutofacAggregateFactoryTests
{
[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Integration\HangfireJobFlow.cs" />
<Compile Include="Integration\HangfireJobSchedulerTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
128 changes: 0 additions & 128 deletions Source/EventFlow.Hangfire.Tests/Integration/HangfireJobFlow.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2016 Rasmus Mikkelsen
// Copyright (c) 2015-2016 eBay Software Foundation
// https://github.com/rasmus/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.Net.Http;
using System.Threading.Tasks;
using EventFlow.Extensions;
using EventFlow.Hangfire.Extensions;
using EventFlow.Hangfire.Integration;
using EventFlow.TestHelpers;
using Hangfire;
using Helpz.MsSql;
using NUnit.Framework;
using EventFlow.Configuration;
using EventFlow.Jobs;
using EventFlow.TestHelpers.Suites;
using FluentAssertions;
using Hangfire.SqlServer;
using Microsoft.Owin.Hosting;

namespace EventFlow.Hangfire.Tests.Integration
{
[Category(Categories.Integration)]
public class HangfireJobSchedulerTests : TestSuiteForScheduler
{
private IMsSqlDatabase _msSqlDatabase;
private IDisposable _webApp;
private BackgroundJobServer _backgroundJobServer;
private EventFlowResolverActivator _eventFlowResolverActivator;

[TestFixtureSetUp]
public void FixtureSetUp()
{
_msSqlDatabase = MsSqlHelpz.CreateDatabase("hangfire");

var sqlServerStorageOptions = new SqlServerStorageOptions
{
QueuePollInterval = TimeSpan.FromSeconds(1),
};
var backgroundJobServerOptions = new BackgroundJobServerOptions
{
SchedulePollingInterval = TimeSpan.FromSeconds(1),
};

GlobalConfiguration.Configuration
.UseSqlServerStorage(_msSqlDatabase.ConnectionString.Value, sqlServerStorageOptions)
.UseActivator(new DelegatingActivator(() => _eventFlowResolverActivator));

_webApp = WebApp.Start("http://127.0.0.1:9001", app => app.UseHangfireDashboard());
_backgroundJobServer = new BackgroundJobServer(backgroundJobServerOptions);
}

[TestFixtureTearDown]
public void FixtureTearDown()
{
_backgroundJobServer.DisposeSafe("Hangfire backgroung job server");
_webApp.DisposeSafe("Web APP");
_msSqlDatabase.DisposeSafe("MSSQL database");
}

private class DelegatingActivator : JobActivator
{
private readonly Func<EventFlowResolverActivator> _eventFlowResolverActivatorFetcher;

public DelegatingActivator(Func<EventFlowResolverActivator> eventFlowResolverActivatorFetcher)
{
_eventFlowResolverActivatorFetcher = eventFlowResolverActivatorFetcher;
}

public override object ActivateJob(Type jobType)
{
return _eventFlowResolverActivatorFetcher().ActivateJob(jobType);
}
}

protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
{
var resolver = eventFlowOptions
.UseHangfireJobScheduler()
.CreateResolver(false);

_eventFlowResolverActivator = new EventFlowResolverActivator(resolver);

return resolver;
}

protected override async Task AssertJobIsSuccessfullAsync(IJobId jobId)
{
var jobHtml = await GetAsync($"hangfire/jobs/details/{jobId.Value}").ConfigureAwait(false);
jobHtml.Should().Contain("<h1 class=\"page-header\">&quot;PublishCommand v1&quot;</h1>");
}

private static async Task<string> GetAsync(string path)
{
using (var httpClient = new HttpClient())
using (var httpResponseMessage = await httpClient.GetAsync(new Uri($"http://127.0.0.1:9001/{path}")))
{
httpResponseMessage.EnsureSuccessStatusCode();
return await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2016 Rasmus Mikkelsen
// Copyright (c) 2015-2016 eBay Software Foundation
// https://github.com/rasmus/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.Commands;
using EventFlow.Core;
using EventFlow.TestHelpers.Aggregates.ValueObjects;
using Newtonsoft.Json;

namespace EventFlow.TestHelpers.Aggregates.Commands
{
[CommandVersion("ThingyMultiplePings", 1)]
public class ThingyMultiplePingsCommand : Command<ThingyAggregate, ThingyId>
{
public IReadOnlyCollection<PingId> PingIds { get; }

public ThingyMultiplePingsCommand(ThingyId aggregateId, IEnumerable<PingId> pingIds)
: this(aggregateId, CommandId.New, pingIds)
{
}

public ThingyMultiplePingsCommand(ThingyId aggregateId, ISourceId sourceId, IEnumerable<PingId> pingIds)
: base (aggregateId, sourceId)
{
PingIds = pingIds.ToList();
}

[JsonConstructor]
public ThingyMultiplePingsCommand(ThingyId aggregateId, SourceId sourceId, IEnumerable<PingId> pingIds)
: base(aggregateId, sourceId)
{
PingIds = pingIds.ToList();
}
}

public class ThingyMultiplePingsCommandHandler : CommandHandler<ThingyAggregate, ThingyId, ThingyMultiplePingsCommand>
{
public override Task ExecuteAsync(ThingyAggregate aggregate, ThingyMultiplePingsCommand command, CancellationToken cancellationToken)
{
foreach (var pingId in command.PingIds)
{
aggregate.Ping(pingId);
}
return Task.FromResult(0);
}
}
}
5 changes: 0 additions & 5 deletions Source/EventFlow.TestHelpers/Categories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ public sealed class Categories
/// </summary>
public const string Integration = "integration";

/// <summary>
/// Tests that execute an in-memory scenario
/// </summary>
public const string Scenario = "scenario";

/// <summary>
/// Tests that test a single class
/// </summary>
Expand Down
Loading

0 comments on commit 7556dad

Please sign in to comment.