Skip to content

Commit

Permalink
Merge pull request #24 from NerosoftDev/refactoring/service-bus
Browse files Browse the repository at this point in the history
Refactoring/service bus
  • Loading branch information
Codespilot authored Nov 29, 2023
2 parents 5469af9 + 0925202 commit 355101b
Show file tree
Hide file tree
Showing 220 changed files with 10,663 additions and 5,537 deletions.
32 changes: 18 additions & 14 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<EnablePackageVersionOverride>true</EnablePackageVersionOverride>
<MicrosoftPackageVersion6>6.0.23</MicrosoftPackageVersion6>
<MicrosoftPackageVersion7>7.0.12</MicrosoftPackageVersion7>
<MicrosoftPackageVersion6>6.0.24</MicrosoftPackageVersion6>
<MicrosoftPackageVersion7>7.0.13</MicrosoftPackageVersion7>
<GrpcAspNetCoreVersion>2.59.0</GrpcAspNetCoreVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Apache.NMS.ActiveMQ" Version="2.1.0"/>
<PackageVersion Include="Autofac" Version="7.1.0"/>
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="8.0.0"/>
<PackageVersion Include="Autofac.Extras.DynamicProxy" Version="7.1.0"/>
<PackageVersion Include="AutoMapper" Version="12.0.1"/>
<PackageVersion Include="Azure.Storage.Blobs" Version="12.18.0"/>
<PackageVersion Include="Azure.Storage.Blobs" Version="12.19.0"/>
<PackageVersion Include="Castle.Core" Version="5.1.1"/>
<PackageVersion Include="Consul" Version="1.6.10.9"/>
<PackageVersion Include="FluentValidation" Version="11.8.0"/>
Expand All @@ -22,7 +24,7 @@
<PackageVersion Include="MediatR.Contracts" Version="2.0.1"/>
<PackageVersion Include="mongocsharpdriver" Version="2.22.0"/>
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageVersion Include="Polly" Version="8.0.0"/>
<PackageVersion Include="Polly" Version="8.1.0"/>
<PackageVersion Include="protobuf-net" Version="3.1.33"/>
<PackageVersion Include="Quartz" Version="3.7.0"/>
<PackageVersion Include="Quartz.Extensions.DependencyInjection" Version="3.7.0"/>
Expand All @@ -31,13 +33,13 @@
<PackageVersion Include="Refit" Version="6.3.2"/>
<PackageVersion Include="Refit.HttpClientFactory" Version="6.3.2"/>
<PackageVersion Include="Refit.Newtonsoft.Json" Version="6.3.2"/>
<PackageVersion Include="Serilog" Version="3.0.1"/>
<PackageVersion Include="Serilog" Version="3.1.1"/>
<PackageVersion Include="Serilog.AspNetCore" Version="7.0.0"/>
<PackageVersion Include="Serilog.Enrichers.Environment" Version="2.3.0"/>
<PackageVersion Include="Serilog.Sinks.Elasticsearch" Version="9.0.3"/>
<PackageVersion Include="Serilog.Sinks.Email" Version="2.4.0"/>
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0"/>
<PackageVersion Include="StackExchange.Redis" Version="2.6.122"/>
<PackageVersion Include="StackExchange.Redis" Version="2.7.4"/>
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
<PackageVersion Include="System.Collections.Immutable" Version="7.0.0"/>
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="7.0.0"/>
Expand Down Expand Up @@ -97,20 +99,22 @@
<!-- Grpc -->
<ItemGroup>
<PackageVersion Include="Google.Api.CommonProtos" Version="2.12.0"/>
<PackageVersion Include="Google.Protobuf" Version="3.24.4"/>
<PackageVersion Include="Google.Protobuf" Version="3.25.0"/>
<PackageVersion Include="Grpc" Version="2.46.6"/>
<PackageVersion Include="Grpc.AspNetCore" Version="2.58.0"/>
<PackageVersion Include="Grpc.AspNetCore.Server" Version="2.58.0"/>
<PackageVersion Include="Grpc.AspNetCore.Server.Reflection" Version="2.58.0"/>
<PackageVersion Include="Grpc.AspNetCore" Version="$(GrpcAspNetCoreVersion)"/>
<PackageVersion Include="Grpc.AspNetCore.HealthChecks" Version="$(GrpcAspNetCoreVersion)"/>
<PackageVersion Include="Grpc.AspNetCore.Server" Version="$(GrpcAspNetCoreVersion)"/>
<PackageVersion Include="Grpc.AspNetCore.Server.Reflection" Version="$(GrpcAspNetCoreVersion)"/>
<PackageVersion Include="Grpc.AspNetCore.Web" Version="$(GrpcAspNetCoreVersion)"/>
<PackageVersion Include="Grpc.Core" Version="2.46.6"/>
<PackageVersion Include="Grpc.HealthCheck" Version="2.58.0"/>
<PackageVersion Include="Grpc.Tools" Version="2.56.0"/>
<PackageVersion Include="Grpc.HealthCheck" Version="$(GrpcAspNetCoreVersion)"/>
<PackageVersion Include="Grpc.Tools" Version="$(GrpcAspNetCoreVersion)"/>
</ItemGroup>
<!-- Tests -->
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.4"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
<PackageVersion Include="xunit" Version="2.5.3"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageVersion Include="xunit" Version="2.6.1"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
54 changes: 54 additions & 0 deletions Euonia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Euonia.Mapping.Tests.Shared
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Core.Tests", "Tests\Euonia.Core.Tests\Euonia.Core.Tests.csproj", "{81D1403E-24B7-47DD-BD55-1D22B8E7756B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Bus.ActiveMq", "Source\Euonia.Bus.ActiveMq\Euonia.Bus.ActiveMq.csproj", "{EFABA5DF-BD24-4880-A9FE-242AACF5B599}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Bus.Abstract", "Source\Euonia.Bus.Abstract\Euonia.Bus.Abstract.csproj", "{31CDB3D0-A7CE-435F-A2A8-CD5F9E7EB8B2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bus", "Bus", "{66B49F2D-FBC6-45A0-82B0-A099CABD37C6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Bus.Tests", "Tests\Euonia.Bus.Tests\Euonia.Bus.Tests.csproj", "{F7ABE0BA-9659-4975-B03D-C383CA13B3D2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Bus.InMemory.Tests", "Tests\Euonia.Bus.InMemory.Tests\Euonia.Bus.InMemory.Tests.csproj", "{AA073AAD-9290-4D55-BFF1-DC1B3357FF8B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Bus.RabbitMq.Tests", "Tests\Euonia.Bus.RabbitMq.Tests\Euonia.Bus.RabbitMq.Tests.csproj", "{C1262DAB-43DB-480A-8064-634C50872258}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Euonia.Bus.Tests.Shared", "Tests\Euonia.Bus.Tests.Shared\Euonia.Bus.Tests.Shared.shproj", "{B2B6A902-17A7-4926-9B7F-22DE8A092231}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -340,6 +354,36 @@ Global
{81D1403E-24B7-47DD-BD55-1D22B8E7756B}.Product|Any CPU.Build.0 = Release|Any CPU
{81D1403E-24B7-47DD-BD55-1D22B8E7756B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81D1403E-24B7-47DD-BD55-1D22B8E7756B}.Release|Any CPU.Build.0 = Release|Any CPU
{EFABA5DF-BD24-4880-A9FE-242AACF5B599}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFABA5DF-BD24-4880-A9FE-242AACF5B599}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFABA5DF-BD24-4880-A9FE-242AACF5B599}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{EFABA5DF-BD24-4880-A9FE-242AACF5B599}.Product|Any CPU.Build.0 = Debug|Any CPU
{EFABA5DF-BD24-4880-A9FE-242AACF5B599}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFABA5DF-BD24-4880-A9FE-242AACF5B599}.Release|Any CPU.Build.0 = Release|Any CPU
{31CDB3D0-A7CE-435F-A2A8-CD5F9E7EB8B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31CDB3D0-A7CE-435F-A2A8-CD5F9E7EB8B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31CDB3D0-A7CE-435F-A2A8-CD5F9E7EB8B2}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{31CDB3D0-A7CE-435F-A2A8-CD5F9E7EB8B2}.Product|Any CPU.Build.0 = Debug|Any CPU
{31CDB3D0-A7CE-435F-A2A8-CD5F9E7EB8B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31CDB3D0-A7CE-435F-A2A8-CD5F9E7EB8B2}.Release|Any CPU.Build.0 = Release|Any CPU
{F7ABE0BA-9659-4975-B03D-C383CA13B3D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7ABE0BA-9659-4975-B03D-C383CA13B3D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7ABE0BA-9659-4975-B03D-C383CA13B3D2}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{F7ABE0BA-9659-4975-B03D-C383CA13B3D2}.Product|Any CPU.Build.0 = Debug|Any CPU
{F7ABE0BA-9659-4975-B03D-C383CA13B3D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7ABE0BA-9659-4975-B03D-C383CA13B3D2}.Release|Any CPU.Build.0 = Release|Any CPU
{AA073AAD-9290-4D55-BFF1-DC1B3357FF8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA073AAD-9290-4D55-BFF1-DC1B3357FF8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA073AAD-9290-4D55-BFF1-DC1B3357FF8B}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{AA073AAD-9290-4D55-BFF1-DC1B3357FF8B}.Product|Any CPU.Build.0 = Debug|Any CPU
{AA073AAD-9290-4D55-BFF1-DC1B3357FF8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA073AAD-9290-4D55-BFF1-DC1B3357FF8B}.Release|Any CPU.Build.0 = Release|Any CPU
{C1262DAB-43DB-480A-8064-634C50872258}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1262DAB-43DB-480A-8064-634C50872258}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1262DAB-43DB-480A-8064-634C50872258}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{C1262DAB-43DB-480A-8064-634C50872258}.Product|Any CPU.Build.0 = Debug|Any CPU
{C1262DAB-43DB-480A-8064-634C50872258}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1262DAB-43DB-480A-8064-634C50872258}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -391,6 +435,13 @@ Global
{34B067D7-7126-4B02-A4E8-E1AFC77F3485} = {0A6E75E4-2AD5-49F3-9120-467A71B471B0}
{DE31E135-48A1-40D8-AFEF-768CEBB4819A} = {0A6E75E4-2AD5-49F3-9120-467A71B471B0}
{81D1403E-24B7-47DD-BD55-1D22B8E7756B} = {E048931D-EC51-448A-A737-3C62CF100813}
{EFABA5DF-BD24-4880-A9FE-242AACF5B599} = {273D1F47-F6AF-4ED5-AAB5-977BD9906B2E}
{31CDB3D0-A7CE-435F-A2A8-CD5F9E7EB8B2} = {273D1F47-F6AF-4ED5-AAB5-977BD9906B2E}
{66B49F2D-FBC6-45A0-82B0-A099CABD37C6} = {E048931D-EC51-448A-A737-3C62CF100813}
{F7ABE0BA-9659-4975-B03D-C383CA13B3D2} = {66B49F2D-FBC6-45A0-82B0-A099CABD37C6}
{AA073AAD-9290-4D55-BFF1-DC1B3357FF8B} = {66B49F2D-FBC6-45A0-82B0-A099CABD37C6}
{C1262DAB-43DB-480A-8064-634C50872258} = {66B49F2D-FBC6-45A0-82B0-A099CABD37C6}
{B2B6A902-17A7-4926-9B7F-22DE8A092231} = {66B49F2D-FBC6-45A0-82B0-A099CABD37C6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {84CDDCF4-F3D0-45FC-87C5-557845F58F55}
Expand All @@ -399,6 +450,9 @@ Global
Tests\Euonia.Mapping.Tests.Shared\Euonia.Mapping.Tests.Shared.projitems*{34b067d7-7126-4b02-a4e8-e1afc77f3485}*SharedItemsImports = 5
Tests\Euonia.Caching.Tests.Shared\Euonia.Caching.Tests.Shared.projitems*{4a28cd6b-0c75-4d39-b613-66de6b693675}*SharedItemsImports = 13
Tests\Euonia.Mapping.Tests.Shared\Euonia.Mapping.Tests.Shared.projitems*{4c27eeef-6837-47ba-bb5c-b0e96fa3504d}*SharedItemsImports = 5
Tests\Euonia.Bus.Tests.Shared\Euonia.Bus.Tests.Shared.projitems*{aa073aad-9290-4d55-bff1-dc1b3357ff8b}*SharedItemsImports = 5
Tests\Euonia.Bus.Tests.Shared\Euonia.Bus.Tests.Shared.projitems*{b2b6a902-17a7-4926-9b7f-22de8a092231}*SharedItemsImports = 13
Tests\Euonia.Bus.Tests.Shared\Euonia.Bus.Tests.Shared.projitems*{c1262dab-43db-480a-8064-634c50872258}*SharedItemsImports = 5
Tests\Euonia.Mapping.Tests.Shared\Euonia.Mapping.Tests.Shared.projitems*{de31e135-48a1-40d8-afef-768cebb4819a}*SharedItemsImports = 13
Tests\Euonia.Caching.Tests.Shared\Euonia.Caching.Tests.Shared.projitems*{efa1cd9d-4b53-483c-bf9d-f21b9b2c6fde}*SharedItemsImports = 5
Tests\Euonia.Caching.Tests.Shared\Euonia.Caching.Tests.Shared.projitems*{f827303e-92c2-46d3-bd8a-50db8885e6ce}*SharedItemsImports = 5
Expand Down
2 changes: 1 addition & 1 deletion Samples/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Nerosoft.Euonia.Sample</RootNamespace>
<Version>7.2.0</Version>
<Version>7.6.0</Version>
<Authors>damon</Authors>
<Company>Nerosoft Co., Ltd.</Company>
<Product>Euonia</Product>
Expand Down
7 changes: 4 additions & 3 deletions Source/Euonia.Application/Behaviors/BearerTokenBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Nerosoft.Euonia.Domain;
using Nerosoft.Euonia.Bus;
using Nerosoft.Euonia.Domain;
using Nerosoft.Euonia.Pipeline;

namespace Nerosoft.Euonia.Application;

/// <summary>
/// A pipeline behavior that adds the bearer token to the command metadata.
/// </summary>
public class BearerTokenBehavior : IPipelineBehavior<ICommand, CommandResponse>
public class BearerTokenBehavior : IPipelineBehavior<RoutedMessage<object>, CommandResponse>
{
private readonly IRequestContextAccessor _contextAccessor;

Expand All @@ -27,7 +28,7 @@ public BearerTokenBehavior(IRequestContextAccessor contextAccessor)
}

/// <inheritdoc />
public async Task<CommandResponse> HandleAsync(ICommand context, PipelineDelegate<ICommand, CommandResponse> next)
public async Task<CommandResponse> HandleAsync(RoutedMessage<object> context, PipelineDelegate<RoutedMessage<object>, CommandResponse> next)
{
if (_contextAccessor?.RequestHeaders.TryGetValue("Authorization", out var values) == true)
{
Expand Down
31 changes: 0 additions & 31 deletions Source/Euonia.Application/Behaviors/CommandLoggingBehavior.cs

This file was deleted.

7 changes: 4 additions & 3 deletions Source/Euonia.Application/Behaviors/UserPrincipalBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nerosoft.Euonia.Claims;
using Nerosoft.Euonia.Bus;
using Nerosoft.Euonia.Claims;
using Nerosoft.Euonia.Domain;
using Nerosoft.Euonia.Pipeline;

Expand All @@ -7,7 +8,7 @@ namespace Nerosoft.Euonia.Application;
/// <summary>
/// A pipeline behavior that adds the user principal to the command metadata.
/// </summary>
public class UserPrincipalBehavior : IPipelineBehavior<ICommand, CommandResponse>
public class UserPrincipalBehavior : IPipelineBehavior<RoutedMessage<object>, CommandResponse>
{
private readonly UserPrincipal _user;

Expand All @@ -28,7 +29,7 @@ public UserPrincipalBehavior(UserPrincipal user)
}

/// <inheritdoc />
public async Task<CommandResponse> HandleAsync(ICommand context, PipelineDelegate<ICommand, CommandResponse> next)
public async Task<CommandResponse> HandleAsync(RoutedMessage<object> context, PipelineDelegate<RoutedMessage<object>, CommandResponse> next)
{
if (_user is { IsAuthenticated: true })
{
Expand Down
122 changes: 61 additions & 61 deletions Source/Euonia.Application/Seedwork/PipelineCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,78 +8,78 @@ namespace Nerosoft.Euonia.Application;
/// </summary>
/// <typeparam name="TCommand"></typeparam>
public class PipelineCommand<TCommand>
where TCommand : ICommand
where TCommand : ICommand
{
/// <summary>
///
/// </summary>
/// <param name="command"></param>
public PipelineCommand(TCommand command)
{
Command = command;
}
/// <summary>
///
/// </summary>
/// <param name="command"></param>
public PipelineCommand(TCommand command)
{
Command = command;
}

/// <summary>
///
/// </summary>
/// <param name="command"></param>
/// <param name="pipeline"></param>
public PipelineCommand(TCommand command, IPipeline<ICommand, CommandResponse> pipeline)
{
Command = command;
Pipeline = pipeline;
}
/// <summary>
///
/// </summary>
/// <param name="command"></param>
/// <param name="pipeline"></param>
public PipelineCommand(TCommand command, IPipeline<ICommand, CommandResponse> pipeline)
{
Command = command;
Pipeline = pipeline;
}

/// <summary>
///
/// </summary>
public TCommand Command { get; }
/// <summary>
///
/// </summary>
public TCommand Command { get; }

/// <summary>
///
/// </summary>
public IPipeline<ICommand, CommandResponse> Pipeline { get; private set; }
/// <summary>
///
/// </summary>
public IPipeline<ICommand, CommandResponse> Pipeline { get; private set; }

/// <summary>
///
/// </summary>
/// <param name="type"></param>
/// <param name="args"></param>
/// <returns></returns>
public PipelineCommand<TCommand> Use(Type type, params object[] args)
{
Pipeline = Pipeline.Use(type, args);
return this;
}
/// <summary>
///
/// </summary>
/// <param name="type"></param>
/// <param name="args"></param>
/// <returns></returns>
public PipelineCommand<TCommand> Use(Type type, params object[] args)
{
Pipeline = Pipeline.Use(type, args);
return this;
}

/// <summary>
///
/// </summary>
/// <typeparam name="TBehavior"></typeparam>
/// <returns></returns>
public PipelineCommand<TCommand> Use<TBehavior>()
where TBehavior : IPipelineBehavior<ICommand, CommandResponse>
{
Pipeline = Pipeline.Use<TBehavior>();
return this;
}
/// <summary>
///
/// </summary>
/// <typeparam name="TBehavior"></typeparam>
/// <returns></returns>
public PipelineCommand<TCommand> Use<TBehavior>()
where TBehavior : IPipelineBehavior<ICommand, CommandResponse>
{
Pipeline = Pipeline.Use<TBehavior>();
return this;
}
}

/// <summary>
/// The extension methods for pipeline command.
/// </summary>
public static class PipelineCommandExtensions
{
/// <summary>
/// Use pipeline.
/// </summary>
/// <param name="command"></param>
/// <param name="pipeline"></param>
/// <typeparam name="TCommand"></typeparam>
/// <returns></returns>
public static PipelineCommand<TCommand> UsePipeline<TCommand>(this TCommand command, IPipeline<ICommand, CommandResponse> pipeline)
where TCommand : ICommand
{
return new PipelineCommand<TCommand>(command, pipeline);
}
/// <summary>
/// Use pipeline.
/// </summary>
/// <param name="command"></param>
/// <param name="pipeline"></param>
/// <typeparam name="TCommand"></typeparam>
/// <returns></returns>
public static PipelineCommand<TCommand> UsePipeline<TCommand>(this TCommand command, IPipeline<ICommand, CommandResponse> pipeline)
where TCommand : ICommand
{
return new PipelineCommand<TCommand>(command, pipeline);
}
}
Loading

0 comments on commit 355101b

Please sign in to comment.