Skip to content

Commit ab0b4a7

Browse files
authored
Split mediator into two packages: abstractions & full implementation (#37)
* add abstraction package * update README.md
1 parent 08bb101 commit ab0b4a7

85 files changed

Lines changed: 166 additions & 146 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ jobs:
5151
if: startsWith(github.ref, 'refs/tags/v')
5252
run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
5353

54-
- name: Pack project
54+
- name: Pack DispatchR project
5555
if: startsWith(github.ref, 'refs/tags/v')
5656
run: dotnet pack src/DispatchR/DispatchR.csproj --configuration Release --no-build -o ./nupkgs /p:PackageVersion=${{ steps.get_version.outputs.version }}
5757

58+
- name: Pack DispatchR Abstractions project
59+
if: startsWith(github.ref, 'refs/tags/v')
60+
run: dotnet pack src/DispatchR.Abstractions/DispatchR.Abstractions.csproj --configuration Release --no-build -o ./nupkgs /p:PackageVersion=${{ steps.get_version.outputs.version }}
61+
5862
- name: Push to NuGet
5963
if: startsWith(github.ref, 'refs/tags/v')
6064
run: dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

DispatchR.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DispatchR.IntegrationTest",
4343
EndProject
4444
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DispatchR.TestCommon", "tests\DispatchR.TestCommon\DispatchR.TestCommon.csproj", "{F01B6563-64D0-4316-947C-AB75426D9924}"
4545
EndProject
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DispatchR.Abstractions", "src\DispatchR.Abstractions\DispatchR.Abstractions.csproj", "{27CFB785-B631-4044-AA90-4B21FA908C0A}"
47+
EndProject
4648
Global
4749
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4850
Debug|Any CPU = Debug|Any CPU
@@ -173,6 +175,18 @@ Global
173175
{F01B6563-64D0-4316-947C-AB75426D9924}.Release|x64.Build.0 = Release|Any CPU
174176
{F01B6563-64D0-4316-947C-AB75426D9924}.Release|x86.ActiveCfg = Release|Any CPU
175177
{F01B6563-64D0-4316-947C-AB75426D9924}.Release|x86.Build.0 = Release|Any CPU
178+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
179+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
180+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Debug|x64.ActiveCfg = Debug|Any CPU
181+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Debug|x64.Build.0 = Debug|Any CPU
182+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Debug|x86.ActiveCfg = Debug|Any CPU
183+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Debug|x86.Build.0 = Debug|Any CPU
184+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
185+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Release|Any CPU.Build.0 = Release|Any CPU
186+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Release|x64.ActiveCfg = Release|Any CPU
187+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Release|x64.Build.0 = Release|Any CPU
188+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Release|x86.ActiveCfg = Release|Any CPU
189+
{27CFB785-B631-4044-AA90-4B21FA908C0A}.Release|x86.Build.0 = Release|Any CPU
176190
EndGlobalSection
177191
GlobalSection(SolutionProperties) = preSolution
178192
HideSolutionNode = FALSE
@@ -191,5 +205,6 @@ Global
191205
{806030F5-86B1-4EFC-923C-94FF7D32DFC9} = {7F7601D5-C62E-4EA3-8B71-E946A62B4529}
192206
{D8646A62-9FE7-4E79-861C-49391007F98A} = {7F7601D5-C62E-4EA3-8B71-E946A62B4529}
193207
{F01B6563-64D0-4316-947C-AB75426D9924} = {7F7601D5-C62E-4EA3-8B71-E946A62B4529}
208+
{27CFB785-B631-4044-AA90-4B21FA908C0A} = {89F559F6-C217-4D24-9A2F-DF25AE215A7C}
194209
EndGlobalSection
195210
EndGlobal

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DispatchR 🚀
1+
# <img src="./icon-mini.png" width="25">ispatchR 🚀
22

33
![CI](https://github.com/hasanxdev/DispatchR/workflows/Release/badge.svg)
44
[![codecov](https://codecov.io/github/hasanxdev/dispatchr/graph/badge.svg?token=1FUG5DPUOE)](https://codecov.io/github/hasanxdev/dispatchr)
@@ -33,6 +33,15 @@
3333
2. `INotificationHandler<TRequestEvent>`
3434
> :bulb: **Tip:** *If you're looking for a mediator with the raw performance of hand-written code, DispatchR is built for you.*
3535
36+
## ✨ How to install?
37+
```
38+
dotnet add package DispatchR.Mediator
39+
```
40+
You can also separately add only the abstractions, which include the interfaces, in another layer:
41+
```
42+
dotnet add package DispatchR.Mediator.Abstractions
43+
```
44+
3645
# Syntax Comparison: DispatchR vs MediatR
3746

3847
###### In the following, you will see the key differences and implementation details between MediatR and DispatchR.
@@ -369,11 +378,6 @@ builder.Services.AddScoped<INotificationHandler<Event>, EventHandler>();
369378
2. Manual registration allows for custom pipeline or notification ordering
370379
3. You can implement custom reflection if needed
371380

372-
## ✨ How to install?
373-
```
374-
dotnet add package DispatchR.Mediator
375-
```
376-
377381
# 🧪 Bechmark Result:
378382
> [!IMPORTANT]
379383
> This benchmark was conducted using MediatR version 12.5.0 and the stable release of Mediator Source Generator, version 2.1.7.

icon-mini.png

8.1 KB
Loading

icon.jpg

237 KB
Loading

src/AspireModularExample/AspireModularSample.Modules/Ping.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DispatchR.Requests.Send;
1+
using DispatchR.Abstractions.Send;
22

33
namespace AspireModularSample.Modules
44
{

src/AspireModularExample/AspireModularSample.Modules/Pong.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DispatchR.Requests.Send;
1+
using DispatchR.Abstractions.Send;
22

33
namespace AspireModularSample.Modules
44
{

src/AspireModularExample/AspireModularSample.ServiceA/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System.Reflection;
22
using AspireModularSample.Modules;
3+
using DispatchR;
34
using DispatchR.Extensions;
4-
using DispatchR.Requests;
5-
using DispatchR.Requests.Send;
65

76
var builder = WebApplication.CreateBuilder(args);
87

src/AspireModularExample/AspireModularSample.ServiceB/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Reflection;
22
using AspireModularSample.Modules;
3+
using DispatchR;
34
using DispatchR.Extensions;
4-
using DispatchR.Requests;
55

66
var builder = WebApplication.CreateBuilder(args);
77

src/Benchmark/Notification/MultiHandlers/MultiHandler0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Benchmark.Notification.MultiHandlers;
55
public sealed class MultiHandler0
66
: INotificationHandler<MultiHandlersNotification>,
77
MediatR.INotificationHandler<MultiHandlersNotification>,
8-
DispatchR.Requests.Notification.INotificationHandler<MultiHandlersNotification>
8+
DispatchR.Abstractions.Notification.INotificationHandler<MultiHandlersNotification>
99
{
1010
public ValueTask Handle(MultiHandlersNotification notification, CancellationToken cancellationToken) => default;
1111

0 commit comments

Comments
 (0)