-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename to command * Use fast type map * Pass over a pre-made generic context instead of converting it in each handler * Added command mapping to the controller base * First version of the service without aggregates * Make the test more like a proper sample * Improved Postgres Projector * Made schema create-drop per test. Slower but can run in parallel. * Added Postgres projector tests * Add sync version to get the command * Registrations and HTTP for functional services
- Loading branch information
1 parent
a29bf4a
commit 0b9e335
Showing
102 changed files
with
2,276 additions
and
896 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String> | ||
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderRegionName/@EntryValue"></s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Esdb/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Eventuous/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=pubsub/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (C) Ubiquitous AS. All rights reserved | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
namespace Eventuous; | ||
|
||
public class MessageMap { | ||
readonly TypeMap<Func<object, object>> _typeMap = new(); | ||
|
||
public MessageMap Add<TIn, TOut>(Func<TIn, TOut> map) where TIn : class where TOut : class { | ||
_typeMap.Add<TIn>(Map); | ||
return this; | ||
|
||
object Map(object inCmd) | ||
=> map((TIn)inCmd); | ||
} | ||
|
||
public TOut Convert<TIn, TOut>(TIn command) where TIn : class { | ||
if (!_typeMap.TryGetValue<TIn>(out var mapper)) { | ||
throw new Exceptions.CommandMappingException<TIn, TOut>(); | ||
} | ||
|
||
return (TOut)mapper(command); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (C) Ubiquitous AS. All rights reserved | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Eventuous; | ||
|
||
public delegate Task<TId> GetIdFromCommandAsync<TId, in TCommand>(TCommand command, CancellationToken cancellationToken) | ||
where TId : AggregateId where TCommand : class; | ||
|
||
public delegate TId GetIdFromCommand<out TId, in TCommand>(TCommand command) where TId : AggregateId where TCommand : class; | ||
|
||
delegate ValueTask<TId> GetIdFromUntypedCommand<TId>(object command, CancellationToken cancellationToken) | ||
where TId : AggregateId; | ||
|
||
class IdMap<TId> where TId : AggregateId { | ||
readonly TypeMap<GetIdFromUntypedCommand<TId>> _typeMap = new(); | ||
|
||
public void AddCommand<TCommand>(GetIdFromCommand<TId, TCommand> getId) where TCommand : class | ||
=> _typeMap.Add<TCommand>((cmd, _) => new ValueTask<TId>(getId((TCommand)cmd))); | ||
|
||
public void AddCommand<TCommand>(GetIdFromCommandAsync<TId, TCommand> getId) where TCommand : class | ||
=> _typeMap.Add<TCommand>(async (cmd, ct) => await getId((TCommand)cmd, ct)); | ||
|
||
internal bool TryGet<TCommand>([NotNullWhen(true)] out GetIdFromUntypedCommand<TId>? getId) where TCommand : class | ||
=> _typeMap.TryGetValue<TCommand>(out getId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) Ubiquitous AS. All rights reserved | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Eventuous; | ||
|
||
public delegate StreamName GetStreamNameFromCommand<in TCommand>(TCommand command) where TCommand : class; | ||
|
||
delegate ValueTask<StreamName> GetStreamNameFromUntypedCommand(object command, CancellationToken cancellationToken); | ||
|
||
public class CommandToStreamMap { | ||
readonly TypeMap<GetStreamNameFromUntypedCommand> _typeMap = new(); | ||
|
||
public void AddCommand<TCommand>(GetStreamNameFromCommand<TCommand> getId) where TCommand : class | ||
=> _typeMap.Add<TCommand>((cmd, _) => new ValueTask<StreamName>(getId((TCommand)cmd))); | ||
|
||
internal bool TryGet<TCommand>([NotNullWhen(true)] out GetStreamNameFromUntypedCommand? getId) where TCommand : class | ||
=> _typeMap.TryGetValue<TCommand>(out getId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.