A simple framework which aims to provide the ability to use a CQRS pattern in your code base, currently with immediate consistency. It does not yet implement or try support Event Sourcing.
Commands: Dispatcher -> Command Reactors -> Command Interceptors -> Command Validators -> Command Handler -> Command Result Reactors -> Audit Store -> Return Result
Command Reactors Are The First Step In The Command Dispatching Pipeline. They Can Be Used As Example For Logging Or To Prime Other Services About An Impending Command.
While The Command Is Passed In By Reference, It Is Not Advised To Edit The Object. The Command Reactor Has No Influence Over Pipeline Execution
These Are Run In Parallel On A Background Thread
This Is The Second Step In The Command Dispatching Pipeline. These Can, Where Required Make Changes To A Command Or Its Properties. They Are Called One After The Other, Not In Parallel.
To Allow Better Seperation Of Concerns This Is The Third Step In The Command Dispatch Pipeline. Command Validators Can Be Implemented For A Given Command. It Can Validate As Required, If Validation Fails The Command Handler Will Not Be Called, Instead The Result Of The Validation Will Be Returned.
While There Can Be Multiple Implementations, The Pipeline Will Return After The First Implementation Returns An Error
Command Result Reactors Are The Final Step In The Command Dispatching Pipeline. The Can Be Used As Example For Logging Or Auditing. The Command Result Reactor Has No Influence Over Pipeline Execution
These Are Run In Parallel On A Background Thread
Command Should Be Used To Alter State In Resources. Commands Must Implement The ICommand Interface.
There Can Only Be A Single Handler For A Command
Queries Are Used To Load Resources. Queries Must Implement The IQuery Interface.
There Can Only Be A Single Handler For A Query
QueryResult Are Objects Which Are Returned From A Query Handler. These Objects Must Implement The IQueryResult Interface. This Interface Is Soley For Tracking Within The Framework And Does Not Impose Any Field Or Property Requirements.
If Commands Do Not Have Implementations Of Command Handlers Registered, They Will Be Checked Firstly By The Microsoft Validator (System.ComponentModel.DataAnnotations.Validator), They Will Also Be Checked If They Implement IValidatableObject (System.ComponentModel.DataAnnotations.IValidatableObject). If Validation Fails The Command Handler Will Not Be Called, Instead The Result Of The Validation Will Be Returned.
The Framework Supports Centralised Auditing, Where Any Command, Query Or Meassage Can Be Logged. Implement The IAuditStore Interface, And Reqister With Dependency Injection. If This Interface Is Found, The Methods Will Be Called. If It Is Not Present, It Is Simply Ignored
Messages Can Be Used To Broadcast To Multiple Handlers
The Dispatcher Supports Either Creating Its Own Or Being Supplied With A Correlation Id.
An Implementation Of This Is Available For Asp.Net Core, Using The Well Known X-Correlation-ID
Header
Command And Query Handlers Can Now Implement The ICorrelationAware Interface. When The Dispatcher Sees That They Implement This Interface, It Will Set The CorrelationId Before Calling The Handle Method.
The Innovation Loader Is Capable Of Loading Assemblies From Specified Locations. This Is To Support A Modular Approach.
- .Net Standard 2.0
- .Net 5.0
There are two samples. Innovation.Sample.Console
and Innovation.Sample.Web
There is a single test project, however there are two other projects in the test directory. This is to ensure that the loading capability can be correctly tested.
In order to build the solution, you will need to following items
- Visual Studio 2019 >= 16.8.3
- Visual Studio .Net Framework Targeting Packs and SDK's for .Net 4.5.1 through .Net 4.6.2 (See Visual Studio Installer - Modify - Individual Components)
- Latest .Net Core SDK Download Link
- Latest .Net Core Runtime Download Link