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 30, 2015
2 parents 970b422 + 9acf3e2 commit 19a5577
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Documentation/Metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ some of its NuGet packages.
is replace with the name of the header. E.g. the
`request_header[Connection]` might contain the value `Keep-Alive`.
* **AddUriMetadataProvider**
* `request_uri` - Adds the OWIN request URI.
* `request_uri` - OWIN request URI.
* `request_method` - OWIN request method.
* **AddUserHostAddressMetadataProvider**
* `user_host_address` - The provider tries to find the correct user
host address by inspecting request headers, i.e., if you have
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# EventFlow

[![NuGet Status](http://img.shields.io/nuget/v/EventFlow.svg?style=flat)](https://www.nuget.org/packages/EventFlow/)
![Build status](https://ci.appveyor.com/api/projects/status/51yvhvbd909e4o82/branch/develop?svg=true)
![License](https://img.shields.io/github/license/rasmus/eventflow.svg)

EventFlow is a basic CQRS+ES framework designed to be easy to use.

Have a look at our [Getting started guide](./Documentation/GettingStarted.md).
Expand Down Expand Up @@ -63,6 +68,7 @@ using (var resolver = EventFlowOptions.New
var testReadModel = await readModelStore.GetAsync(id);
}
```

## Useful links

* [CQRS Journey by Microsoft](https://msdn.microsoft.com/en-us/library/jj554200.aspx)
Expand Down
5 changes: 5 additions & 0 deletions Source/EventFlow.EventStores.MsSql/MssqlEventStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ protected override async Task<IReadOnlyCollection<ICommittedDomainEvent>> Commit
IReadOnlyCollection<SerializedEvent> serializedEvents,
CancellationToken cancellationToken)
{
if (!serializedEvents.Any())
{
return new ICommittedDomainEvent[] {};
}

var batchId = Guid.NewGuid();
var aggregateType = typeof(TAggregate);
var aggregateName = aggregateType.Name.Replace("Aggregate", string.Empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public IEnumerable<KeyValuePair<string, string>> ProvideMetadata<TAggregate>(
// TODO: Handle X-Forwarded-Proto header

yield return new KeyValuePair<string, string>("request_uri", _owinContext.Request.Uri.ToString());
yield return new KeyValuePair<string, string>("request_method", _owinContext.Request.Method.ToUpperInvariant());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// The MIT License (MIT)
//
// Copyright (c) 2015 Rasmus Mikkelsen
// 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.Threading;
using System.Threading.Tasks;
using EventFlow.Commands;

namespace EventFlow.TestHelpers.Aggregates.Test.Commands
{
public class DoesNothingCommand : Command<TestAggregate>
{
public DoesNothingCommand(string id) : base(id)
{
}
}

public class DoesNothingCommandHandler : CommandHandler<TestAggregate, DoesNothingCommand>
{
public override Task ExecuteAsync(TestAggregate aggregate, DoesNothingCommand command, CancellationToken cancellationToken)
{
return Task.FromResult(0);
}
}
}
1 change: 1 addition & 0 deletions Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Aggregates\Test\Commands\DoesNothingCommand.cs" />
<Compile Include="Aggregates\Test\Commands\DomainErrorAfterFirstCommand.cs" />
<Compile Include="Aggregates\Test\Commands\PingCommand.cs" />
<Compile Include="Aggregates\Test\Events\DomainErrorAfterFirstEvent.cs" />
Expand Down
11 changes: 11 additions & 0 deletions Source/EventFlow.TestHelpers/Suites/EventStoreSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ public async Task AggregateEventStreamsAreSeperate()
aggregate2.Version.Should().Be(2);
}

[Test]
public async Task NoEventsEmittedIsOk()
{
// Arrange
var id = A<string>();
var aggregate = await EventStore.LoadAggregateAsync<TestAggregate>(id, CancellationToken.None).ConfigureAwait(false);

// Act
await aggregate.CommitAsync(EventStore, CancellationToken.None).ConfigureAwait(false);
}

[Test]
public async Task OptimisticConcurrency()
{
Expand Down
5 changes: 5 additions & 0 deletions Source/EventFlow/EventStores/EventStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public virtual async Task<IReadOnlyCollection<IDomainEvent>> StoreAsync<TAggrega
CancellationToken cancellationToken)
where TAggregate : IAggregateRoot
{
if (!uncommittedDomainEvents.Any())
{
return new IDomainEvent[] {};
}

var aggregateType = typeof (TAggregate);
Log.Verbose(
"Storing {0} events for aggregate '{1}' with ID '{2}'",
Expand Down
2 changes: 1 addition & 1 deletion Source/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Reflection;

[assembly: AssemblyVersionAttribute("0.0.1")]
[assembly: AssemblyInformationalVersionAttribute("0.0.1-alpha")]
[assembly: AssemblyInformationalVersionAttribute("0.0.1")]
[assembly: AssemblyFileVersionAttribute("0.0.1")]
namespace System {
internal static class AssemblyVersionInformation {
Expand Down
2 changes: 1 addition & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let filePathUnitTestReport = dirReports + "/NUnit.xml"
let fileListUnitTests = !! ("**/bin/" @@ buildMode @@ "/EventFlow*Tests.dll")
let toolNUnit = "./Tools/NUnit.Runners/tools"
let toolIlMerge = "./Tools/ilmerge/tools/ILMerge.exe"
let nugetVersion = buildVersion + "-alpha"
let nugetVersion = buildVersion // + "-alpha"
let nugetVersionDep = "["+nugetVersion+"]"

Target "Clean" (fun _ ->
Expand Down

0 comments on commit 19a5577

Please sign in to comment.