From d284bb069fb4e76058feaecc5f184e6ad2383bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:22:23 +0300 Subject: [PATCH 01/20] Added empty Volo.Abp.Dapr package --- common.DotSettings | 1 + framework/Volo.Abp.sln | 7 +++++ framework/src/Volo.Abp.Dapr/AbpDaprModule.cs | 8 +++++ framework/src/Volo.Abp.Dapr/FodyWeavers.xml | 3 ++ framework/src/Volo.Abp.Dapr/FodyWeavers.xsd | 30 +++++++++++++++++++ .../src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj | 20 +++++++++++++ nupkg/common.ps1 | 1 + 7 files changed, 70 insertions(+) create mode 100644 framework/src/Volo.Abp.Dapr/AbpDaprModule.cs create mode 100644 framework/src/Volo.Abp.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj diff --git a/common.DotSettings b/common.DotSettings index 5c1cda48fd..f2cc0339ae 100644 --- a/common.DotSettings +++ b/common.DotSettings @@ -38,5 +38,6 @@ False False False + True True \ No newline at end of file diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index fadd40bcc5..f86448ee20 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -409,6 +409,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.RemoteServices", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.PlugIn", "test\Volo.Abp.AspNetCore.Mvc.PlugIn\Volo.Abp.AspNetCore.Mvc.PlugIn.csproj", "{C6D6D878-208A-4FD2-822E-365545D8681B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Dapr", "src\Volo.Abp.Dapr\Volo.Abp.Dapr.csproj", "{192A829F-D608-4E41-8DE0-058E943E453F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1219,6 +1221,10 @@ Global {C6D6D878-208A-4FD2-822E-365545D8681B}.Debug|Any CPU.Build.0 = Debug|Any CPU {C6D6D878-208A-4FD2-822E-365545D8681B}.Release|Any CPU.ActiveCfg = Release|Any CPU {C6D6D878-208A-4FD2-822E-365545D8681B}.Release|Any CPU.Build.0 = Release|Any CPU + {192A829F-D608-4E41-8DE0-058E943E453F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {192A829F-D608-4E41-8DE0-058E943E453F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1425,6 +1431,7 @@ Global {3683340D-92F5-4B14-B77B-34A163333309} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {EDFFDA74-090D-439C-A58D-06CCF86D4423} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {C6D6D878-208A-4FD2-822E-365545D8681B} = {447C8A77-E5F0-4538-8687-7383196D04EA} + {192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/AbpDaprModule.cs new file mode 100644 index 0000000000..d69d1088f4 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/AbpDaprModule.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Modularity; + +namespace Volo.Abp.Dapr; + +public class AbpDaprModule : AbpModule +{ + +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..00e1d9a1c1 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj new file mode 100644 index 0000000000..c8b3297a4a --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj @@ -0,0 +1,20 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index f13746aed0..f05b16db52 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -155,6 +155,7 @@ $projects = ( "framework/src/Volo.Abp.Core", "framework/src/Volo.Abp", "framework/src/Volo.Abp.Dapper", + "framework/src/Volo.Abp.Dapr", "framework/src/Volo.Abp.Data", "framework/src/Volo.Abp.Ddd.Application", "framework/src/Volo.Abp.Ddd.Application.Contracts", From 6f9750fa50ef224f7bc03329115b25abcf98a175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:26:17 +0300 Subject: [PATCH 02/20] Added Volo.Abp.EventBus.Dapr package. --- framework/Volo.Abp.sln | 7 +++++ framework/src/Volo.Abp.Dapr/FodyWeavers.xml | 2 +- .../AbpEventBusDaprModule.cs | 12 ++++++++ .../Volo.Abp.EventBus.Dapr/FodyWeavers.xml | 3 ++ .../Volo.Abp.EventBus.Dapr/FodyWeavers.xsd | 30 +++++++++++++++++++ .../Volo.Abp.EventBus.Dapr.csproj | 17 +++++++++++ nupkg/common.ps1 | 1 + 7 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index f86448ee20..b3516c9f6e 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -411,6 +411,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Plu EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Dapr", "src\Volo.Abp.Dapr\Volo.Abp.Dapr.csproj", "{192A829F-D608-4E41-8DE0-058E943E453F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Dapr", "src\Volo.Abp.EventBus.Dapr\Volo.Abp.EventBus.Dapr.csproj", "{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1225,6 +1227,10 @@ Global {192A829F-D608-4E41-8DE0-058E943E453F}.Debug|Any CPU.Build.0 = Debug|Any CPU {192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.ActiveCfg = Release|Any CPU {192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.Build.0 = Release|Any CPU + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1432,6 +1438,7 @@ Global {EDFFDA74-090D-439C-A58D-06CCF86D4423} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {C6D6D878-208A-4FD2-822E-365545D8681B} = {447C8A77-E5F0-4538-8687-7383196D04EA} {192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.Dapr/FodyWeavers.xml index 00e1d9a1c1..be0de3a908 100644 --- a/framework/src/Volo.Abp.Dapr/FodyWeavers.xml +++ b/framework/src/Volo.Abp.Dapr/FodyWeavers.xml @@ -1,3 +1,3 @@  - + \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs b/framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs new file mode 100644 index 0000000000..8d054c6bd7 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.EventBus.Dapr; + +[DependsOn( + typeof(AbpEventBusModule), + typeof(AbpDaprModule) + )] +public class AbpEventBusDaprModule : AbpModule +{ +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj new file mode 100644 index 0000000000..51985afeff --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj @@ -0,0 +1,17 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index f05b16db52..ce7fb491ed 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -176,6 +176,7 @@ $projects = ( "framework/src/Volo.Abp.EventBus.Kafka", "framework/src/Volo.Abp.EventBus.Rebus", "framework/src/Volo.Abp.EventBus.Azure", + "framework/src/Volo.Abp.EventBus.Dapr", "framework/src/Volo.Abp.ExceptionHandling", "framework/src/Volo.Abp.Features", "framework/src/Volo.Abp.FluentValidation", From e8ab404420ffbd2e183d24a41e735441858b663b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:29:17 +0300 Subject: [PATCH 03/20] Added Volo.Abp.Http.Client.Dapr package. --- framework/Volo.Abp.sln | 7 +++++ .../AbpHttpClientDaprModule.cs | 12 ++++++++ .../Volo.Abp.Http.Client.Dapr/FodyWeavers.xml | 3 ++ .../Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd | 30 +++++++++++++++++++ .../Volo.Abp.Http.Client.Dapr.csproj | 17 +++++++++++ nupkg/common.ps1 | 3 +- 6 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index b3516c9f6e..79b0eeabc7 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -413,6 +413,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Dapr", "src\Volo.A EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Dapr", "src\Volo.Abp.EventBus.Dapr\Volo.Abp.EventBus.Dapr.csproj", "{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Client.Dapr", "src\Volo.Abp.Http.Client.Dapr\Volo.Abp.Http.Client.Dapr.csproj", "{18B796D2-D45D-41AE-9A42-75C9B14B20DF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1231,6 +1233,10 @@ Global {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Debug|Any CPU.Build.0 = Debug|Any CPU {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.ActiveCfg = Release|Any CPU {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.Build.0 = Release|Any CPU + {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1439,6 +1445,7 @@ Global {C6D6D878-208A-4FD2-822E-365545D8681B} = {447C8A77-E5F0-4538-8687-7383196D04EA} {192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs new file mode 100644 index 0000000000..8d9a73290f --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Http.Client.Dapr; + +[DependsOn( + typeof(AbpHttpClientModule), + typeof(AbpDaprModule) + )] +public class AbpHttpClientDaprModule : AbpModule +{ +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj new file mode 100644 index 0000000000..a0d49df593 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj @@ -0,0 +1,17 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index ce7fb491ed..968d60b94a 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -186,7 +186,8 @@ $projects = ( "framework/src/Volo.Abp.HangFire", "framework/src/Volo.Abp.Http.Abstractions", "framework/src/Volo.Abp.Http.Client", - "framework/src/Volo.Abp.Http.Client.Web", + "framework/src/Volo.Abp.Http.Client.Dapr", + "framework/src/Volo.Abp.Http.Client.Web", "framework/src/Volo.Abp.Http.Client.IdentityModel", "framework/src/Volo.Abp.Http.Client.IdentityModel.Web", "framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly", From f1871b8bb2d86f7bc1aeed4970523627dce577f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:38:30 +0300 Subject: [PATCH 04/20] Created empty Volo.Abp.AspNetCore.Dapr package. --- framework/Volo.Abp.sln | 7 +++++ .../AbpAspNetCoreDaprModule.cs | 13 ++++++++ .../Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml | 3 ++ .../Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd | 30 +++++++++++++++++++ .../Volo.Abp.AspNetCore.Dapr.csproj | 21 +++++++++++++ nupkg/common.ps1 | 1 + 6 files changed, 75 insertions(+) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index 79b0eeabc7..b97935b3c1 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -415,6 +415,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Dapr", "s EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Client.Dapr", "src\Volo.Abp.Http.Client.Dapr\Volo.Abp.Http.Client.Dapr.csproj", "{18B796D2-D45D-41AE-9A42-75C9B14B20DF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr", "src\Volo.Abp.AspNetCore.Dapr\Volo.Abp.AspNetCore.Dapr.csproj", "{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1237,6 +1239,10 @@ Global {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Debug|Any CPU.Build.0 = Debug|Any CPU {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.ActiveCfg = Release|Any CPU {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.Build.0 = Release|Any CPU + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1446,6 +1452,7 @@ Global {192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs new file mode 100644 index 0000000000..3f84054b5e --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Dapr; + +[DependsOn( + typeof(AbpAspNetCoreModule), + typeof(AbpDaprModule) + )] +public class AbpAspNetCoreDaprModule : AbpModule +{ + +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj new file mode 100644 index 0000000000..05d5de4042 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj @@ -0,0 +1,21 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + + + + + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index 968d60b94a..c020554e5e 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -99,6 +99,7 @@ $projects = ( "framework/src/Volo.Abp.AspNetCore.Authentication.OAuth", "framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect", "framework/src/Volo.Abp.AspNetCore", + "framework/src/Volo.Abp.AspNetCore.Dapr", "framework/src/Volo.Abp.AspNetCore.Components", "framework/src/Volo.Abp.AspNetCore.Components.Server", "framework/src/Volo.Abp.AspNetCore.Components.Web", From 4be7bc3fb6926cc01a5f852bf4249fef390fcd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:41:45 +0300 Subject: [PATCH 05/20] Set rootnamespaces to empty for the new dapr integration packages. --- .../src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj | 1 + .../{ => Volo/Abp/AspNetCore/Dapr}/AbpAspNetCoreDaprModule.cs | 0 framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj | 1 + framework/src/Volo.Abp.Dapr/{ => Volo/Abp/Dapr}/AbpDaprModule.cs | 0 .../src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj | 1 + .../{ => Volo/Abp/EventBus/Dapr}/AbpEventBusDaprModule.cs | 0 .../Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj | 1 + .../{ => Volo/Abp/Http/Client/Dapr}/AbpHttpClientDaprModule.cs | 0 8 files changed, 4 insertions(+) rename framework/src/Volo.Abp.AspNetCore.Dapr/{ => Volo/Abp/AspNetCore/Dapr}/AbpAspNetCoreDaprModule.cs (100%) rename framework/src/Volo.Abp.Dapr/{ => Volo/Abp/Dapr}/AbpDaprModule.cs (100%) rename framework/src/Volo.Abp.EventBus.Dapr/{ => Volo/Abp/EventBus/Dapr}/AbpEventBusDaprModule.cs (100%) rename framework/src/Volo.Abp.Http.Client.Dapr/{ => Volo/Abp/Http/Client/Dapr}/AbpHttpClientDaprModule.cs (100%) diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj index 05d5de4042..43bfc66df8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj @@ -7,6 +7,7 @@ net6.0 enable enable + diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs similarity index 100% rename from framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs diff --git a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj index c8b3297a4a..5ba8d313e1 100644 --- a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj +++ b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj @@ -7,6 +7,7 @@ net6.0 enable enable + diff --git a/framework/src/Volo.Abp.Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs similarity index 100% rename from framework/src/Volo.Abp.Dapr/AbpDaprModule.cs rename to framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj index 51985afeff..2bef3f9dc9 100644 --- a/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj @@ -7,6 +7,7 @@ net6.0 enable enable + diff --git a/framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs similarity index 100% rename from framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs rename to framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj index a0d49df593..909fb156c8 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj @@ -7,6 +7,7 @@ net6.0 enable enable + diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs similarity index 100% rename from framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs rename to framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs From b9b7fbf51bf4ab5cc9985113e2417217aaf7986f Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 5 Aug 2022 11:18:40 +0800 Subject: [PATCH 06/20] Add `AbpDaprOptions`. --- .../src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs | 11 ++++++++--- .../src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs index d69d1088f4..e7f09e3c13 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs @@ -1,8 +1,13 @@ -using Volo.Abp.Modularity; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; namespace Volo.Abp.Dapr; public class AbpDaprModule : AbpModule { - -} \ No newline at end of file + public override void ConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + Configure(configuration.GetSection("Dapr")); + } +} diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs new file mode 100644 index 0000000000..e6919783af --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.Dapr; + +public class AbpDaprOptions +{ + public string HttpEndpoint { get; set; } + + public string GrpcEndpoint { get; set; } +} From d6455db2bde22e2f0bd6e60db3fdc7ceae6cc018 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Aug 2022 14:03:06 +0800 Subject: [PATCH 07/20] Add `AbpDaprClientFactory`. --- .../Volo/Abp/Dapr/AbpDaprClientFactory.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs new file mode 100644 index 0000000000..2237547155 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs @@ -0,0 +1,25 @@ +using Dapr.Client; +using Microsoft.Extensions.Options; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Dapr; + +public class AbpDaprClientFactory : ITransientDependency +{ + protected AbpDaprOptions Options { get; } + + public AbpDaprClientFactory(IOptions options) + { + Options = options.Value; + } + + public virtual Task CreateAsync() + { + var daprClient = new DaprClientBuilder() + .UseHttpEndpoint(Options.HttpEndpoint) + //.UseJsonSerializationOptions()//TODO: Use abp JsonSerializerOptions + .Build(); + + return Task.FromResult(daprClient); + } +} From 000f32e6b45d5588d2a6c69b7595702710b2300f Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Aug 2022 14:21:57 +0800 Subject: [PATCH 08/20] Use abp JsonSerializerOptions in `AbpDaprClientFactory`. --- .../Volo/Abp/Dapr/AbpDaprClientFactory.cs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs index 2237547155..1cd37ceb94 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs @@ -1,25 +1,44 @@ -using Dapr.Client; +using System.Collections.Concurrent; +using System.Text.Json; +using Dapr.Client; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; +using Volo.Abp.Json.SystemTextJson; namespace Volo.Abp.Dapr; public class AbpDaprClientFactory : ITransientDependency { protected AbpDaprOptions Options { get; } + protected AbpSystemTextJsonSerializerOptions SystemTextJsonSerializerOptions { get; } - public AbpDaprClientFactory(IOptions options) + public AbpDaprClientFactory( + IOptions options, + IOptions systemTextJsonSerializerOptions) { Options = options.Value; + SystemTextJsonSerializerOptions = systemTextJsonSerializerOptions.Value; } - public virtual Task CreateAsync() + public virtual async Task CreateAsync() { - var daprClient = new DaprClientBuilder() + var builder = new DaprClientBuilder() .UseHttpEndpoint(Options.HttpEndpoint) - //.UseJsonSerializationOptions()//TODO: Use abp JsonSerializerOptions - .Build(); + .UseJsonSerializationOptions(await CreateJsonSerializerOptions()); - return Task.FromResult(daprClient); + if (!Options.GrpcEndpoint.IsNullOrWhiteSpace()) + { + builder.UseGrpcEndpoint(Options.GrpcEndpoint); + } + + return builder.Build(); + } + + private readonly static ConcurrentDictionary JsonSerializerOptionsCache = new ConcurrentDictionary(); + + protected virtual Task CreateJsonSerializerOptions() + { + return Task.FromResult(JsonSerializerOptionsCache.GetOrAdd(nameof(AbpDaprClientFactory), + _ => new JsonSerializerOptions(SystemTextJsonSerializerOptions.JsonSerializerOptions))); } } From 24a13f4c2934a9c3ec2fc26ed4fed96c6e653f4e Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Aug 2022 14:40:46 +0800 Subject: [PATCH 09/20] Update AbpDaprModule.cs --- framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs index e7f09e3c13..43d6d11033 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs @@ -1,8 +1,10 @@ using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Json; using Volo.Abp.Modularity; namespace Volo.Abp.Dapr; +[DependsOn(typeof(AbpJsonModule))] public class AbpDaprModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) From 54e9c6736e551d4ae091828fec1832d4de047c6d Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Aug 2022 14:46:21 +0800 Subject: [PATCH 10/20] Update Volo.Abp.Dapr.csproj --- framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj index 5ba8d313e1..8c8b53ed91 100644 --- a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj +++ b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj @@ -12,6 +12,7 @@ + From 4a724493b99ce515178a5fa192b35cf09301c22f Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 9 Aug 2022 15:28:43 +0800 Subject: [PATCH 11/20] Implement the Dapr event bus. --- .../Volo.Abp.AspNetCore.Dapr.csproj | 8 +- .../Dapr/AbpAspNetCoreDaprConsts.cs | 8 + .../Dapr/AbpAspNetCoreDaprModule.cs | 26 ++- .../Dapr/AbpAspNetCoreDaprOptions.cs | 11 + .../AspNetCore/Dapr/AbpDaprPubSubProvider.cs | 63 +++++ ...AbpDaprPubSubProviderContributorContext.cs | 16 ++ .../Dapr/Controllers/DaprController.cs | 44 ++++ .../Dapr/IAbpDaprPubSubProviderContributor.cs | 6 + .../Dapr/Models/DaprSubscriptionDefinition.cs | 10 + .../Dapr/Models/DaprSubscriptionRequest.cs | 8 + .../AbpAspNetCoreDaprJsonNamingPolicy.cs | 11 + .../DaprSubscriptionDefinitionConverter.cs | 25 ++ .../Volo/Abp/Dapr/AbpDaprClientFactory.cs | 6 +- .../Volo/Abp/Dapr/IDaprSerializer.cs | 16 ++ .../Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs | 45 ++++ .../EventBus/Dapr/AbpDaprEventBusOptions.cs | 11 + .../EventBus/Dapr/AbpEventBusDaprModule.cs | 12 +- .../EventBus/Dapr/DaprDistributedEventBus.cs | 221 ++++++++++++++++++ 18 files changed, 539 insertions(+), 8 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs create mode 100644 framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs create mode 100644 framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpDaprEventBusOptions.cs create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj index 43bfc66df8..747593eb3f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj @@ -7,11 +7,13 @@ net6.0 enable enable - + + + @@ -19,4 +21,8 @@ + + + + diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs new file mode 100644 index 0000000000..7011d25476 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpAspNetCoreDaprConsts +{ + public const string DaprSubscribeUrl = "dapr/subscribe"; + + public const string DaprEventCallbackUrl = "api/abp/dapr/event"; +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs index 3f84054b5e..52e5820c4c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs @@ -1,13 +1,31 @@ -using Volo.Abp.Dapr; +using Microsoft.AspNetCore.Http.Json; +using Volo.Abp.AspNetCore.Dapr.SystemTextJson; +using Volo.Abp.EventBus.Dapr; +using Volo.Abp.Json; +using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Dapr; [DependsOn( typeof(AbpAspNetCoreModule), - typeof(AbpDaprModule) + typeof(AbpEventBusDaprModule), + typeof(AbpJsonModule) )] public class AbpAspNetCoreDaprModule : AbpModule { - -} \ No newline at end of file + public override void ConfigureServices(ServiceConfigurationContext context) + { + // TODO: Add NewtonsoftJson json converter. + + Configure(options => + { + options.SerializerOptions.Converters.Add(new DaprSubscriptionDefinitionConverter()); + }); + + Configure(options => + { + options.JsonSerializerOptions.Converters.Add(new DaprSubscriptionDefinitionConverter()); + }); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs new file mode 100644 index 0000000000..17667d24b9 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpAspNetCoreDaprOptions +{ + public List Contributors { get; } + + public AbpAspNetCoreDaprOptions() + { + Contributors = new List(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs new file mode 100644 index 0000000000..27eaa294d5 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs @@ -0,0 +1,63 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.AspNetCore.Dapr.Models; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus; +using Volo.Abp.EventBus.Dapr; +using Volo.Abp.EventBus.Distributed; + +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpDaprPubSubProvider : ITransientDependency +{ + protected IServiceProvider ServiceProvider { get; } + protected AbpAspNetCoreDaprOptions Options { get; } + protected AbpDaprEventBusOptions EventBusOptions { get; } + protected AbpDistributedEventBusOptions DistributedEventBusOptions { get; } + + public AbpDaprPubSubProvider( + IServiceProvider serviceProvider, + IOptions options, + IOptions eventBusOptions, + IOptions distributedEventBusOptions) + { + ServiceProvider = serviceProvider; + EventBusOptions = eventBusOptions.Value; + Options = options.Value; + DistributedEventBusOptions = distributedEventBusOptions.Value; + } + + public virtual async Task> GetSubscriptionsAsync() + { + var subscriptions = new List(); + foreach (var handler in DistributedEventBusOptions.Handlers) + { + foreach (var @interface in handler.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDistributedEventHandler<>))) + { + var eventType = @interface.GetGenericArguments()[0]; + var eventName = EventNameAttribute.GetNameOrDefault(eventType); + + subscriptions.Add(new DaprSubscriptionDefinition() + { + PubSubName = EventBusOptions.PubSubName, + Topic = eventName, + Route = AbpAspNetCoreDaprConsts.DaprEventCallbackUrl + }); + } + } + + if (Options.Contributors.Any()) + { + using (var scope = ServiceProvider.CreateScope()) + { + var context = new AbpDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions); + foreach (var contributor in Options.Contributors) + { + await contributor.ContributeAsync(context); + } + } + } + + return subscriptions; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs new file mode 100644 index 0000000000..e2428e992a --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs @@ -0,0 +1,16 @@ +using Volo.Abp.AspNetCore.Dapr.Models; + +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpDaprPubSubProviderContributorContext +{ + public IServiceProvider ServiceProvider { get; } + + public List Subscriptions { get; } + + public AbpDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels) + { + ServiceProvider = serviceProvider; + Subscriptions = daprSubscriptionModels; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs new file mode 100644 index 0000000000..b28fbf6e7a --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs @@ -0,0 +1,44 @@ +using System.Text.Json; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.AspNetCore.Dapr.Models; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Dapr; +using Volo.Abp.EventBus.Dapr; + +namespace Volo.Abp.AspNetCore.Dapr.Controllers; + +[Area("abp")] +[RemoteService(Name = "abp")] +public class DaprController : AbpController +{ + protected AbpDaprPubSubProvider DaprPubSubProvider { get; } + + public DaprController(AbpDaprPubSubProvider daprPubSubProvider) + { + DaprPubSubProvider = daprPubSubProvider; + } + + [HttpGet(AbpAspNetCoreDaprConsts.DaprSubscribeUrl)] + public virtual async Task> SubscribeAsync() + { + return await DaprPubSubProvider.GetSubscriptionsAsync(); + } + + [HttpPost(AbpAspNetCoreDaprConsts.DaprEventCallbackUrl)] + public virtual async Task EventsAsync() + { + var bodyJsonDocument = await JsonDocument.ParseAsync(HttpContext.Request.Body); + var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(), + HttpContext.RequestServices.GetRequiredService>().Value.JsonSerializerOptions); + + var distributedEventBus = HttpContext.RequestServices.GetRequiredService(); + var daprSerializer = HttpContext.RequestServices.GetRequiredService(); + + var eventData = daprSerializer.Deserialize(bodyJsonDocument.RootElement.GetProperty("data").GetRawText(), distributedEventBus.GetEventType(request.Topic)); + await distributedEventBus.TriggerHandlersAsync(distributedEventBus.GetEventType(request.Topic), eventData); + + return Ok(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs new file mode 100644 index 0000000000..1a23483f9d --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public interface IAbpDaprPubSubProviderContributor +{ + Task ContributeAsync(AbpDaprPubSubProviderContributorContext context); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs new file mode 100644 index 0000000000..6fd8077250 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.AspNetCore.Dapr.Models; + +public class DaprSubscriptionDefinition +{ + public string PubSubName { get; set; } + + public string Topic { get; set; } + + public string Route { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs new file mode 100644 index 0000000000..9f7f4dfd4f --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.AspNetCore.Dapr.Models; + +public class DaprSubscriptionRequest +{ + public string PubSubName { get; set; } + + public string Topic { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs new file mode 100644 index 0000000000..e682d283e9 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs @@ -0,0 +1,11 @@ +using System.Text.Json; + +namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; + +public class AbpAspNetCoreDaprJsonNamingPolicy : JsonNamingPolicy +{ + public override string ConvertName(string name) + { + return name.ToLower(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs new file mode 100644 index 0000000000..e2168da993 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs @@ -0,0 +1,25 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Volo.Abp.AspNetCore.Dapr.Models; + +namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; + +public class DaprSubscriptionDefinitionConverter : JsonConverter +{ + private JsonSerializerOptions _writeJsonSerializerOptions; + + public override DaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + throw new NotSupportedException(); + } + + public override void Write(Utf8JsonWriter writer, DaprSubscriptionDefinition value, JsonSerializerOptions options) + { + _writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(new JsonSerializerOptions(options) + { + PropertyNamingPolicy = new AbpAspNetCoreDaprJsonNamingPolicy() + }, x => x == this); + + JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions); + } +} diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs index 1cd37ceb94..faaf450ddc 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs @@ -23,9 +23,13 @@ public class AbpDaprClientFactory : ITransientDependency public virtual async Task CreateAsync() { var builder = new DaprClientBuilder() - .UseHttpEndpoint(Options.HttpEndpoint) .UseJsonSerializationOptions(await CreateJsonSerializerOptions()); + if (!Options.HttpEndpoint.IsNullOrWhiteSpace()) + { + builder.UseHttpEndpoint(Options.HttpEndpoint); + } + if (!Options.GrpcEndpoint.IsNullOrWhiteSpace()) { builder.UseGrpcEndpoint(Options.GrpcEndpoint); diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs new file mode 100644 index 0000000000..7eec2c5c1c --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs @@ -0,0 +1,16 @@ +namespace Volo.Abp.Dapr; + +public interface IDaprSerializer +{ + byte[] Serialize(object obj); + + object Deserialize(byte[] value, Type type); + + T Deserialize(byte[] value); + + string SerializeToString(object obj); + + object Deserialize(string value, Type type); + + T Deserialize(string value); +} diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs new file mode 100644 index 0000000000..ce9b4a8523 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs @@ -0,0 +1,45 @@ +using System.Text; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Json; + +namespace Volo.Abp.Dapr; + +public class Utf8JsonDaprSerializer : IDaprSerializer, ITransientDependency +{ + private readonly IJsonSerializer _jsonSerializer; + + public Utf8JsonDaprSerializer(IJsonSerializer jsonSerializer) + { + _jsonSerializer = jsonSerializer; + } + + public byte[] Serialize(object obj) + { + return Encoding.UTF8.GetBytes(_jsonSerializer.Serialize(obj)); + } + + public object Deserialize(byte[] value, Type type) + { + return _jsonSerializer.Deserialize(type, Encoding.UTF8.GetString(value)); + } + + public T Deserialize(byte[] value) + { + return _jsonSerializer.Deserialize(Encoding.UTF8.GetString(value)); + } + + public string SerializeToString(object obj) + { + return _jsonSerializer.Serialize(obj); + } + + public object Deserialize(string value, Type type) + { + return _jsonSerializer.Deserialize(type, value); + } + + public T Deserialize(string value) + { + return _jsonSerializer.Deserialize(value); + } +} diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpDaprEventBusOptions.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpDaprEventBusOptions.cs new file mode 100644 index 0000000000..d3ced52ba2 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpDaprEventBusOptions.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.EventBus.Dapr; + +public class AbpDaprEventBusOptions +{ + public string PubSubName { get; set; } + + public AbpDaprEventBusOptions() + { + PubSubName = "pubsub"; + } +} diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs index 8d054c6bd7..5f6329a4bc 100644 --- a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Dapr; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Dapr; using Volo.Abp.Modularity; namespace Volo.Abp.EventBus.Dapr; @@ -9,4 +10,11 @@ namespace Volo.Abp.EventBus.Dapr; )] public class AbpEventBusDaprModule : AbpModule { -} \ No newline at end of file + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + context + .ServiceProvider + .GetRequiredService() + .Initialize(); + } +} diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs new file mode 100644 index 0000000000..1f241b9c6d --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs @@ -0,0 +1,221 @@ +using System.Collections.Concurrent; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.Dapr; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Guids; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Threading; +using Volo.Abp.Timing; +using Volo.Abp.Uow; + +namespace Volo.Abp.EventBus.Dapr; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IDistributedEventBus), typeof(DaprDistributedEventBus))] +public class DaprDistributedEventBus : DistributedEventBusBase, ISingletonDependency +{ + protected IDaprSerializer Serializer { get; } + protected AbpDaprEventBusOptions DaprEventBusOptions { get; } + protected AbpDaprClientFactory DaprClientFactory { get; } + + protected ConcurrentDictionary> HandlerFactories { get; } + protected ConcurrentDictionary EventTypes { get; } + + public DaprDistributedEventBus( + IServiceScopeFactory serviceScopeFactory, + ICurrentTenant currentTenant, + IUnitOfWorkManager unitOfWorkManager, + IOptions abpDistributedEventBusOptions, + IGuidGenerator guidGenerator, + IClock clock, + IEventHandlerInvoker eventHandlerInvoker, + IDaprSerializer serializer, + IOptions daprEventBusOptions, + AbpDaprClientFactory daprClientFactory) + : base(serviceScopeFactory, currentTenant, unitOfWorkManager, abpDistributedEventBusOptions, guidGenerator, clock, eventHandlerInvoker) + { + Serializer = serializer; + DaprEventBusOptions = daprEventBusOptions.Value; + DaprClientFactory = daprClientFactory; + + HandlerFactories = new ConcurrentDictionary>(); + EventTypes = new ConcurrentDictionary(); + } + + public void Initialize() + { + SubscribeHandlers(AbpDistributedEventBusOptions.Handlers); + } + + public override IDisposable Subscribe(Type eventType, IEventHandlerFactory factory) + { + var handlerFactories = GetOrCreateHandlerFactories(eventType); + + if (factory.IsInFactories(handlerFactories)) + { + return NullDisposable.Instance; + } + + handlerFactories.Add(factory); + + return new EventHandlerFactoryUnregistrar(this, eventType, factory); + } + + public override void Unsubscribe(Func action) + { + Check.NotNull(action, nameof(action)); + + GetOrCreateHandlerFactories(typeof(TEvent)) + .Locking(factories => + { + factories.RemoveAll( + factory => + { + var singleInstanceFactory = factory as SingleInstanceHandlerFactory; + if (singleInstanceFactory == null) + { + return false; + } + + var actionHandler = singleInstanceFactory.HandlerInstance as ActionEventHandler; + if (actionHandler == null) + { + return false; + } + + return actionHandler.Action == action; + }); + }); + } + + public override void Unsubscribe(Type eventType, IEventHandler handler) + { + GetOrCreateHandlerFactories(eventType) + .Locking(factories => + { + factories.RemoveAll( + factory => + factory is SingleInstanceHandlerFactory && + (factory as SingleInstanceHandlerFactory).HandlerInstance == handler + ); + }); + } + + public override void Unsubscribe(Type eventType, IEventHandlerFactory factory) + { + GetOrCreateHandlerFactories(eventType).Locking(factories => factories.Remove(factory)); + } + + public override void UnsubscribeAll(Type eventType) + { + GetOrCreateHandlerFactories(eventType).Locking(factories => factories.Clear()); + } + + protected async override Task PublishToEventBusAsync(Type eventType, object eventData) + { + await PublishToDaprAsync(eventType, eventData); + } + + protected override void AddToUnitOfWork(IUnitOfWork unitOfWork, UnitOfWorkEventRecord eventRecord) + { + unitOfWork.AddOrReplaceDistributedEvent(eventRecord); + } + + protected override IEnumerable GetHandlerFactories(Type eventType) + { + var handlerFactoryList = new List(); + + foreach (var handlerFactory in HandlerFactories.Where(hf => ShouldTriggerEventForHandler(eventType, hf.Key))) + { + handlerFactoryList.Add(new EventTypeWithEventHandlerFactories(handlerFactory.Key, handlerFactory.Value)); + } + + return handlerFactoryList.ToArray(); + } + + public async override Task PublishFromOutboxAsync(OutgoingEventInfo outgoingEvent, OutboxConfig outboxConfig) + { + await PublishToDaprAsync(outgoingEvent.EventName, Serializer.Deserialize(outgoingEvent.EventData, GetEventType(outgoingEvent.EventName))); + } + + public async override Task PublishManyFromOutboxAsync(IEnumerable outgoingEvents, OutboxConfig outboxConfig) + { + var outgoingEventArray = outgoingEvents.ToArray(); + + foreach (var outgoingEvent in outgoingEventArray) + { + await PublishToDaprAsync(outgoingEvent.EventName, Serializer.Deserialize(outgoingEvent.EventData, GetEventType(outgoingEvent.EventName))); + } + } + + public async override Task ProcessFromInboxAsync(IncomingEventInfo incomingEvent, InboxConfig inboxConfig) + { + var eventType = EventTypes.GetOrDefault(incomingEvent.EventName); + if (eventType == null) + { + return; + } + + var eventData = Serializer.Deserialize(incomingEvent.EventData, eventType); + var exceptions = new List(); + await TriggerHandlersAsync(eventType, eventData, exceptions, inboxConfig); + if (exceptions.Any()) + { + ThrowOriginalExceptions(eventType, exceptions); + } + } + + protected override byte[] Serialize(object eventData) + { + return Serializer.Serialize(eventData); + } + + private List GetOrCreateHandlerFactories(Type eventType) + { + return HandlerFactories.GetOrAdd( + eventType, + type => + { + var eventName = EventNameAttribute.GetNameOrDefault(type); + EventTypes[eventName] = type; + return new List(); + } + ); + } + + public Type GetEventType(string eventName) + { + return EventTypes.GetOrDefault(eventName); + } + + protected virtual async Task PublishToDaprAsync(Type eventType, object eventData) + { + await PublishToDaprAsync(EventNameAttribute.GetNameOrDefault(eventType), eventData); + } + + protected virtual async Task PublishToDaprAsync(string eventName, object eventData) + { + var client = await DaprClientFactory.CreateAsync(); + await client.PublishEventAsync(pubsubName: DaprEventBusOptions.PubSubName, topicName: eventName, data: eventData); + } + + private static bool ShouldTriggerEventForHandler(Type targetEventType, Type handlerEventType) + { + //Should trigger same type + if (handlerEventType == targetEventType) + { + return true; + } + + //TODO: Support inheritance? But it does not support on subscription to RabbitMq! + //Should trigger for inherited types + if (handlerEventType.IsAssignableFrom(targetEventType)) + { + return true; + } + + return false; + } +} From bccd1155906b0a0c34a711e3f27165516c9432fe Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 9 Aug 2022 18:04:45 +0800 Subject: [PATCH 12/20] Implement the Dapr http client --- .../Http/Client/Dapr/AbpDaprClientOptions.cs | 24 +++++++++++++++++++ .../Client/Dapr/AbpHttpClientDaprModule.cs | 20 +++++++++++++--- ...viceCollectionHttpClientProxyExtensions.cs | 2 +- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs new file mode 100644 index 0000000000..b2504acd9c --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs @@ -0,0 +1,24 @@ +using Dapr.Client; +using Microsoft.Extensions.DependencyInjection; + +namespace Volo.Abp.Http.Client.Dapr; + +public class AbpDaprClientOptions +{ + public Action DaprHttpClientBuilderAction { get; set; } + + public AbpDaprClientOptions() + { + DaprHttpClientBuilderAction = DefaultDaprHttpClientBuilder; + } + + private void DefaultDaprHttpClientBuilder(string serviceName, IHttpClientBuilder clientBuilder, string daprEndpoint) + { + Check.NotNull(daprEndpoint, nameof(daprEndpoint)); + + clientBuilder.AddHttpMessageHandler(() => new InvocationHandler + { + DaprEndpoint = daprEndpoint + }); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs index 8d9a73290f..1b24510842 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Dapr; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Dapr; using Volo.Abp.Modularity; namespace Volo.Abp.Http.Client.Dapr; @@ -6,7 +7,20 @@ namespace Volo.Abp.Http.Client.Dapr; [DependsOn( typeof(AbpHttpClientModule), typeof(AbpDaprModule) - )] +)] public class AbpHttpClientDaprModule : AbpModule -{ +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + var daprOptions = context.Services.ExecutePreConfiguredActions(); + var daprClientOptions = context.Services.ExecutePreConfiguredActions(); + + PreConfigure(options => + { + options.ProxyClientBuildActions.Add((_, clientBuilder) => + { + daprClientOptions.DaprHttpClientBuilderAction(_, clientBuilder, daprOptions.HttpEndpoint); + }); + }); + } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs index 4ccac104cd..7bc239813d 100644 --- a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs +++ b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs @@ -212,7 +212,7 @@ public static class ServiceCollectionHttpClientProxyExtensions } /// - /// Checks wether the type is suitable to use with the proxying. + /// Checks whether the type is suitable to use with the proxying. /// Currently the type is checked statically against some fixed conditions. /// /// Type to check From c559fa4335d7f8909319f1c5d5a075c484353943 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 9 Aug 2022 20:25:25 +0800 Subject: [PATCH 13/20] Add AbpInvocationHandler --- .../Abp/Http/Client/Dapr/AbpDaprClientOptions.cs | 14 ++++---------- .../Http/Client/Dapr/AbpHttpClientDaprModule.cs | 3 +-- .../Abp/Http/Client/Dapr/AbpInvocationHandler.cs | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs index b2504acd9c..e6fa2d35dd 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs @@ -1,24 +1,18 @@ -using Dapr.Client; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; namespace Volo.Abp.Http.Client.Dapr; public class AbpDaprClientOptions { - public Action DaprHttpClientBuilderAction { get; set; } + public Action DaprHttpClientBuilderAction { get; set; } public AbpDaprClientOptions() { DaprHttpClientBuilderAction = DefaultDaprHttpClientBuilder; } - private void DefaultDaprHttpClientBuilder(string serviceName, IHttpClientBuilder clientBuilder, string daprEndpoint) + private void DefaultDaprHttpClientBuilder(string serviceName, IHttpClientBuilder clientBuilder) { - Check.NotNull(daprEndpoint, nameof(daprEndpoint)); - - clientBuilder.AddHttpMessageHandler(() => new InvocationHandler - { - DaprEndpoint = daprEndpoint - }); + clientBuilder.AddHttpMessageHandler(); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs index 1b24510842..374fca198e 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs @@ -12,14 +12,13 @@ public class AbpHttpClientDaprModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - var daprOptions = context.Services.ExecutePreConfiguredActions(); var daprClientOptions = context.Services.ExecutePreConfiguredActions(); PreConfigure(options => { options.ProxyClientBuildActions.Add((_, clientBuilder) => { - daprClientOptions.DaprHttpClientBuilderAction(_, clientBuilder, daprOptions.HttpEndpoint); + daprClientOptions.DaprHttpClientBuilderAction(_, clientBuilder); }); }); } diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs new file mode 100644 index 0000000000..a3397b55e4 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs @@ -0,0 +1,14 @@ +using Dapr.Client; +using Microsoft.Extensions.Options; +using Volo.Abp.Dapr; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Http.Client.Dapr; + +public class AbpInvocationHandler : InvocationHandler, ITransientDependency +{ + public AbpInvocationHandler(IOptions daprOptions) + { + DaprEndpoint = daprOptions.Value.HttpEndpoint; + } +} \ No newline at end of file From 4d6987a99f269817832d763b666209df47755f34 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 11 Aug 2022 16:06:38 +0800 Subject: [PATCH 14/20] Add `framework/src/Volo.Abp.AspNetCore.Dapr.EventBus` package. --- framework/Volo.Abp.sln | 7 ++++ .../FodyWeavers.xml | 3 ++ .../FodyWeavers.xsd | 30 +++++++++++++++++ .../Volo.Abp.AspNetCore.Dapr.EventBus.csproj | 17 ++++++++++ .../AbpAspNetCoreDaprEventBusModule.cs | 31 ++++++++++++++++++ .../AbpAspNetCoreDaprEventBusOptions.cs | 11 +++++++ .../AbpAspNetCoreDaprPubSubConsts.cs} | 2 +- .../AbpAspNetCoreDaprPubSubProvider.cs} | 32 +++++++++---------- ...oreDaprPubSubProviderContributorContext.cs | 16 ++++++++++ .../AbpAspNetCoreDaprPubSubController.cs} | 19 ++++------- ...AspNetCoreDaprPubSubProviderContributor.cs | 6 ++++ ...bpAspNetCoreDaprSubscriptionDefinition.cs} | 2 +- .../AbpAspNetCoreDaprSubscriptionRequest.cs} | 2 +- ...bpAspNetCoreDaprPubSubJsonNamingPolicy.cs} | 2 +- ...oreDaprSubscriptionDefinitionConverter.cs} | 8 ++--- .../Volo.Abp.AspNetCore.Dapr.csproj | 7 ---- .../Dapr/AbpAspNetCoreDaprModule.cs | 25 ++------------- .../Dapr/AbpAspNetCoreDaprOptions.cs | 11 ------- ...AbpDaprPubSubProviderContributorContext.cs | 16 ---------- .../Dapr/IAbpDaprPubSubProviderContributor.cs | 6 ---- nupkg/common.ps1 | 1 + 21 files changed, 155 insertions(+), 99 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs} (80%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs} (54%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs} (65%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs} (76%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs} (72%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs} (71%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs} (52%) delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index b97935b3c1..5578e2d7c3 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -417,6 +417,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Client.Dapr", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr", "src\Volo.Abp.AspNetCore.Dapr\Volo.Abp.AspNetCore.Dapr.csproj", "{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr.EventBus", "src\Volo.Abp.AspNetCore.Dapr.EventBus\Volo.Abp.AspNetCore.Dapr.EventBus.csproj", "{B02EF042-C39E-45C4-A92D-BF7554E1889D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1243,6 +1245,10 @@ Global {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Debug|Any CPU.Build.0 = Debug|Any CPU {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.ActiveCfg = Release|Any CPU {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.Build.0 = Release|Any CPU + {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1453,6 +1459,7 @@ Global {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {B02EF042-C39E-45C4-A92D-BF7554E1889D} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj new file mode 100644 index 0000000000..0c9280a27e --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj @@ -0,0 +1,17 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs new file mode 100644 index 0000000000..b4fd636e76 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Http.Json; +using Volo.Abp.AspNetCore.Dapr.SystemTextJson; +using Volo.Abp.EventBus.Dapr; +using Volo.Abp.Json; +using Volo.Abp.Json.SystemTextJson; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Dapr; + +[DependsOn( + typeof(AbpAspNetCoreDaprModule), + typeof(AbpEventBusDaprModule), + typeof(AbpJsonModule) + )] +public class AbpAspNetCoreDaprEventBusModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + // TODO: Add NewtonsoftJson json converter. + + Configure(options => + { + options.SerializerOptions.Converters.Add(new AbpAspNetCoreDaprSubscriptionDefinitionConverter()); + }); + + Configure(options => + { + options.JsonSerializerOptions.Converters.Add(new AbpAspNetCoreDaprSubscriptionDefinitionConverter()); + }); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs new file mode 100644 index 0000000000..be65464428 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpAspNetCoreDaprEventBusOptions +{ + public List Contributors { get; } + + public AbpAspNetCoreDaprEventBusOptions() + { + Contributors = new List(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs similarity index 80% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs index 7011d25476..c0cfb9d5cc 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Dapr; -public class AbpAspNetCoreDaprConsts +public class AbpAspNetCoreDaprPubSubConsts { public const string DaprSubscribeUrl = "dapr/subscribe"; diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs similarity index 54% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs index 27eaa294d5..0affd70bba 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs @@ -8,28 +8,28 @@ using Volo.Abp.EventBus.Distributed; namespace Volo.Abp.AspNetCore.Dapr; -public class AbpDaprPubSubProvider : ITransientDependency +public class AbpAspNetCoreDaprPubSubProvider : ITransientDependency { protected IServiceProvider ServiceProvider { get; } - protected AbpAspNetCoreDaprOptions Options { get; } - protected AbpDaprEventBusOptions EventBusOptions { get; } + protected AbpAspNetCoreDaprEventBusOptions AspNetCoreDaprEventBusOptions { get; } + protected AbpDaprEventBusOptions DaprEventBusOptions { get; } protected AbpDistributedEventBusOptions DistributedEventBusOptions { get; } - public AbpDaprPubSubProvider( + public AbpAspNetCoreDaprPubSubProvider( IServiceProvider serviceProvider, - IOptions options, - IOptions eventBusOptions, + IOptions aspNetCoreDaprEventBusOptions, + IOptions daprEventBusOptions, IOptions distributedEventBusOptions) { ServiceProvider = serviceProvider; - EventBusOptions = eventBusOptions.Value; - Options = options.Value; + AspNetCoreDaprEventBusOptions = aspNetCoreDaprEventBusOptions.Value; + DaprEventBusOptions = daprEventBusOptions.Value; DistributedEventBusOptions = distributedEventBusOptions.Value; } - public virtual async Task> GetSubscriptionsAsync() + public virtual async Task> GetSubscriptionsAsync() { - var subscriptions = new List(); + var subscriptions = new List(); foreach (var handler in DistributedEventBusOptions.Handlers) { foreach (var @interface in handler.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDistributedEventHandler<>))) @@ -37,21 +37,21 @@ public class AbpDaprPubSubProvider : ITransientDependency var eventType = @interface.GetGenericArguments()[0]; var eventName = EventNameAttribute.GetNameOrDefault(eventType); - subscriptions.Add(new DaprSubscriptionDefinition() + subscriptions.Add(new AbpAspNetCoreDaprSubscriptionDefinition() { - PubSubName = EventBusOptions.PubSubName, + PubSubName = DaprEventBusOptions.PubSubName, Topic = eventName, - Route = AbpAspNetCoreDaprConsts.DaprEventCallbackUrl + Route = AbpAspNetCoreDaprPubSubConsts.DaprEventCallbackUrl }); } } - if (Options.Contributors.Any()) + if (AspNetCoreDaprEventBusOptions.Contributors.Any()) { using (var scope = ServiceProvider.CreateScope()) { - var context = new AbpDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions); - foreach (var contributor in Options.Contributors) + var context = new AbpAspNetCoreDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions); + foreach (var contributor in AspNetCoreDaprEventBusOptions.Contributors) { await contributor.ContributeAsync(context); } diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs new file mode 100644 index 0000000000..93cb43b0bf --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs @@ -0,0 +1,16 @@ +using Volo.Abp.AspNetCore.Dapr.Models; + +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpAspNetCoreDaprPubSubProviderContributorContext +{ + public IServiceProvider ServiceProvider { get; } + + public List Subscriptions { get; } + + public AbpAspNetCoreDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels) + { + ServiceProvider = serviceProvider; + Subscriptions = daprSubscriptionModels; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs similarity index 65% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs index b28fbf6e7a..e2440d90ce 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs @@ -11,26 +11,19 @@ namespace Volo.Abp.AspNetCore.Dapr.Controllers; [Area("abp")] [RemoteService(Name = "abp")] -public class DaprController : AbpController +public class AbpAspNetCoreDaprPubSubController : AbpController { - protected AbpDaprPubSubProvider DaprPubSubProvider { get; } - - public DaprController(AbpDaprPubSubProvider daprPubSubProvider) - { - DaprPubSubProvider = daprPubSubProvider; - } - - [HttpGet(AbpAspNetCoreDaprConsts.DaprSubscribeUrl)] - public virtual async Task> SubscribeAsync() + [HttpGet(AbpAspNetCoreDaprPubSubConsts.DaprSubscribeUrl)] + public virtual async Task> SubscribeAsync() { - return await DaprPubSubProvider.GetSubscriptionsAsync(); + return await HttpContext.RequestServices.GetRequiredService().GetSubscriptionsAsync(); } - [HttpPost(AbpAspNetCoreDaprConsts.DaprEventCallbackUrl)] + [HttpPost(AbpAspNetCoreDaprPubSubConsts.DaprEventCallbackUrl)] public virtual async Task EventsAsync() { var bodyJsonDocument = await JsonDocument.ParseAsync(HttpContext.Request.Body); - var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(), + var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(), HttpContext.RequestServices.GetRequiredService>().Value.JsonSerializerOptions); var distributedEventBus = HttpContext.RequestServices.GetRequiredService(); diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs new file mode 100644 index 0000000000..da9f7564de --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public interface IAbpAspNetCoreDaprPubSubProviderContributor +{ + Task ContributeAsync(AbpAspNetCoreDaprPubSubProviderContributorContext context); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs similarity index 76% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs index 6fd8077250..414a69fbf1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Dapr.Models; -public class DaprSubscriptionDefinition +public class AbpAspNetCoreDaprSubscriptionDefinition { public string PubSubName { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs similarity index 72% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs index 9f7f4dfd4f..1dd88b1015 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Dapr.Models; -public class DaprSubscriptionRequest +public class AbpAspNetCoreDaprSubscriptionRequest { public string PubSubName { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs similarity index 71% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs index e682d283e9..f6d4605ff2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; -public class AbpAspNetCoreDaprJsonNamingPolicy : JsonNamingPolicy +public class AbpAspNetCoreDaprPubSubJsonNamingPolicy : JsonNamingPolicy { public override string ConvertName(string name) { diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs similarity index 52% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs index e2168da993..c0699ece43 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs @@ -4,20 +4,20 @@ using Volo.Abp.AspNetCore.Dapr.Models; namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; -public class DaprSubscriptionDefinitionConverter : JsonConverter +public class AbpAspNetCoreDaprSubscriptionDefinitionConverter : JsonConverter { private JsonSerializerOptions _writeJsonSerializerOptions; - public override DaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override AbpAspNetCoreDaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { throw new NotSupportedException(); } - public override void Write(Utf8JsonWriter writer, DaprSubscriptionDefinition value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, AbpAspNetCoreDaprSubscriptionDefinition value, JsonSerializerOptions options) { _writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(new JsonSerializerOptions(options) { - PropertyNamingPolicy = new AbpAspNetCoreDaprJsonNamingPolicy() + PropertyNamingPolicy = new AbpAspNetCoreDaprPubSubJsonNamingPolicy() }, x => x == this); JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions); diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj index 747593eb3f..51c2a097b9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj @@ -12,17 +12,10 @@ - - - - - - - diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs index 52e5820c4c..1650efa667 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs @@ -1,31 +1,12 @@ -using Microsoft.AspNetCore.Http.Json; -using Volo.Abp.AspNetCore.Dapr.SystemTextJson; -using Volo.Abp.EventBus.Dapr; -using Volo.Abp.Json; -using Volo.Abp.Json.SystemTextJson; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Dapr; [DependsOn( - typeof(AbpAspNetCoreModule), - typeof(AbpEventBusDaprModule), - typeof(AbpJsonModule) - )] + typeof(AbpAspNetCoreMvcModule) +)] public class AbpAspNetCoreDaprModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) - { - // TODO: Add NewtonsoftJson json converter. - Configure(options => - { - options.SerializerOptions.Converters.Add(new DaprSubscriptionDefinitionConverter()); - }); - - Configure(options => - { - options.JsonSerializerOptions.Converters.Add(new DaprSubscriptionDefinitionConverter()); - }); - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs deleted file mode 100644 index 17667d24b9..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.AspNetCore.Dapr; - -public class AbpAspNetCoreDaprOptions -{ - public List Contributors { get; } - - public AbpAspNetCoreDaprOptions() - { - Contributors = new List(); - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs deleted file mode 100644 index e2428e992a..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Volo.Abp.AspNetCore.Dapr.Models; - -namespace Volo.Abp.AspNetCore.Dapr; - -public class AbpDaprPubSubProviderContributorContext -{ - public IServiceProvider ServiceProvider { get; } - - public List Subscriptions { get; } - - public AbpDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels) - { - ServiceProvider = serviceProvider; - Subscriptions = daprSubscriptionModels; - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs deleted file mode 100644 index 1a23483f9d..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Volo.Abp.AspNetCore.Dapr; - -public interface IAbpDaprPubSubProviderContributor -{ - Task ContributeAsync(AbpDaprPubSubProviderContributorContext context); -} diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index c020554e5e..a2df36ae42 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -100,6 +100,7 @@ $projects = ( "framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect", "framework/src/Volo.Abp.AspNetCore", "framework/src/Volo.Abp.AspNetCore.Dapr", + "framework/src/Volo.Abp.AspNetCore.Dapr.EventBus", "framework/src/Volo.Abp.AspNetCore.Components", "framework/src/Volo.Abp.AspNetCore.Components.Server", "framework/src/Volo.Abp.AspNetCore.Components.Web", From b7d5ad768ac49d60b418b7a0e538f7f0ff440a68 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 11 Aug 2022 18:15:55 +0800 Subject: [PATCH 15/20] Implement the Dapr DistributedLock --- framework/Volo.Abp.sln | 7 +++ .../Volo/Abp/Dapr/AbpDaprOptions.cs | 2 + .../FodyWeavers.xml | 3 ++ .../FodyWeavers.xsd | 30 +++++++++++ .../Volo.Abp.DistributedLocking.Dapr.csproj | 18 +++++++ .../Dapr/AbpDistributedLockDaprOptions.cs | 6 +++ .../Dapr/AbpDistributedLockingDaprModule.cs | 11 ++++ .../Dapr/DaprAbpDistributedLock.cs | 50 +++++++++++++++++++ .../Dapr/DaprAbpDistributedLockHandle.cs | 18 +++++++ .../AbpDistributedLockingModule.cs | 1 - nupkg/common.ps1 | 1 + 11 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index 5578e2d7c3..f6eba4386d 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -419,6 +419,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr.EventBus", "src\Volo.Abp.AspNetCore.Dapr.EventBus\Volo.Abp.AspNetCore.Dapr.EventBus.csproj", "{B02EF042-C39E-45C4-A92D-BF7554E1889D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.DistributedLocking.Dapr", "src\Volo.Abp.DistributedLocking.Dapr\Volo.Abp.DistributedLocking.Dapr.csproj", "{CAE48068-233C-47A9-BEAB-DDF521730E7A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1249,6 +1251,10 @@ Global {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Debug|Any CPU.Build.0 = Debug|Any CPU {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.ActiveCfg = Release|Any CPU {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.Build.0 = Release|Any CPU + {CAE48068-233C-47A9-BEAB-DDF521730E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAE48068-233C-47A9-BEAB-DDF521730E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAE48068-233C-47A9-BEAB-DDF521730E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAE48068-233C-47A9-BEAB-DDF521730E7A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1460,6 +1466,7 @@ Global {18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {B02EF042-C39E-45C4-A92D-BF7554E1889D} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {CAE48068-233C-47A9-BEAB-DDF521730E7A} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs index e6919783af..9d743263c5 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs @@ -2,6 +2,8 @@ public class AbpDaprOptions { + public string AppId { get; set; } + public string HttpEndpoint { get; set; } public string GrpcEndpoint { get; set; } diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..00e1d9a1c1 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj new file mode 100644 index 0000000000..80cad677a3 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj @@ -0,0 +1,18 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + + diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs new file mode 100644 index 0000000000..a2ff732932 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.DistributedLocking.Dapr; + +public class AbpDistributedLockDaprOptions +{ + public string StoreName { get; set; } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs new file mode 100644 index 0000000000..c915cfe2f7 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.DistributedLocking.Dapr; + +[DependsOn( + typeof(AbpDistributedLockingAbstractionsModule), + typeof(AbpDaprModule))] +public class AbpDistributedLockingDaprModule : AbpModule +{ +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs new file mode 100644 index 0000000000..d74d7497fc --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs @@ -0,0 +1,50 @@ +using Microsoft.Extensions.Options; +using Volo.Abp.Dapr; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.DistributedLocking.Dapr; + +[Dependency(ReplaceServices = true)] +public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency +{ + protected AbpDaprClientFactory DaprClientFactory { get; } + protected AbpDistributedLockDaprOptions DistributedLockDaprOptions { get; } + protected AbpDaprOptions DaprOptions { get; } + + public DaprAbpDistributedLock( + AbpDaprClientFactory daprClientFactory, + IOptions distributedLockDaprOptions, + IOptions daprOptions) + { + DaprClientFactory = daprClientFactory; + DaprOptions = daprOptions.Value; + DistributedLockDaprOptions = distributedLockDaprOptions.Value; + } + + public async Task TryAcquireAsync( + string name, + TimeSpan timeout = default, + CancellationToken cancellationToken = default) + { + if (timeout == default) + { + timeout = TimeSpan.FromSeconds(30); + } + + var daprClient = await DaprClientFactory.CreateAsync(); + + var lockResponse = await daprClient.Lock( + DistributedLockDaprOptions.StoreName, + name, + DaprOptions.AppId, + timeout.Seconds, + cancellationToken); + + if (lockResponse == null || !lockResponse.Success) + { + return null; + } + + return new DaprAbpDistributedLockHandle(lockResponse); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs new file mode 100644 index 0000000000..b10f0f3672 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs @@ -0,0 +1,18 @@ +using Dapr.Client; + +namespace Volo.Abp.DistributedLocking.Dapr; + +public class DaprAbpDistributedLockHandle : IAbpDistributedLockHandle +{ + protected TryLockResponse LockResponse { get; } + + public DaprAbpDistributedLockHandle(TryLockResponse lockResponse) + { + LockResponse = lockResponse; + } + + public async ValueTask DisposeAsync() + { + await LockResponse.DisposeAsync(); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking/Volo/Abp/DistributedLocking/AbpDistributedLockingModule.cs b/framework/src/Volo.Abp.DistributedLocking/Volo/Abp/DistributedLocking/AbpDistributedLockingModule.cs index 4c4abd3f32..c642e33667 100644 --- a/framework/src/Volo.Abp.DistributedLocking/Volo/Abp/DistributedLocking/AbpDistributedLockingModule.cs +++ b/framework/src/Volo.Abp.DistributedLocking/Volo/Abp/DistributedLocking/AbpDistributedLockingModule.cs @@ -7,5 +7,4 @@ namespace Volo.Abp.DistributedLocking; )] public class AbpDistributedLockingModule : AbpModule { - } diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index a2df36ae42..65e2d46324 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -164,6 +164,7 @@ $projects = ( "framework/src/Volo.Abp.Ddd.Domain", "framework/src/Volo.Abp.DistributedLocking.Abstractions", "framework/src/Volo.Abp.DistributedLocking", + "framework/src/Volo.Abp.DistributedLocking.Dapr", "framework/src/Volo.Abp.Emailing", "framework/src/Volo.Abp.EntityFrameworkCore", "framework/src/Volo.Abp.EntityFrameworkCore.MySQL", From ecd834ca3524be8645e4947e8cd78eb50769626b Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 11 Aug 2022 20:37:30 +0800 Subject: [PATCH 16/20] Add DefaultTimeout --- .../DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs | 2 ++ .../Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs index a2ff732932..6938300f9b 100644 --- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs @@ -3,4 +3,6 @@ public class AbpDistributedLockDaprOptions { public string StoreName { get; set; } + + public TimeSpan DefaultTimeout { get; set;} } \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs index d74d7497fc..7f95a56542 100644 --- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs @@ -28,7 +28,7 @@ public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency { if (timeout == default) { - timeout = TimeSpan.FromSeconds(30); + timeout = DistributedLockDaprOptions.DefaultTimeout; } var daprClient = await DaprClientFactory.CreateAsync(); @@ -37,7 +37,7 @@ public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency DistributedLockDaprOptions.StoreName, name, DaprOptions.AppId, - timeout.Seconds, + (int)timeout.TotalSeconds, cancellationToken); if (lockResponse == null || !lockResponse.Success) From 47431aad449deb65d047358aa48d9ec36ae64695 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 11 Aug 2022 20:38:16 +0800 Subject: [PATCH 17/20] Update AbpDistributedLockDaprOptions --- .../Dapr/AbpDistributedLockDaprOptions.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs index 6938300f9b..43feba3c3b 100644 --- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs @@ -4,5 +4,10 @@ public class AbpDistributedLockDaprOptions { public string StoreName { get; set; } - public TimeSpan DefaultTimeout { get; set;} + public TimeSpan DefaultTimeout { get; set; } + + public AbpDistributedLockDaprOptions() + { + DefaultTimeout = TimeSpan.FromSeconds(30); + } } \ No newline at end of file From eb883c36b93b00e910d2c63dfcc5836b6c44743e Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 22 Aug 2022 13:43:54 +0800 Subject: [PATCH 18/20] Update framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Halil İbrahim Kalkan --- framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml index 00e1d9a1c1..be0de3a908 100644 --- a/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml @@ -1,3 +1,3 @@  - + \ No newline at end of file From f96ee789ad18bb22b1fb8490950a7c3ccab3bdeb Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 22 Aug 2022 15:35:51 +0800 Subject: [PATCH 19/20] Update package name. --- framework/Volo.Abp.sln | 4 +-- .../AbpAspNetCoreDaprEventBusOptions.cs | 11 -------- ...oreDaprPubSubProviderContributorContext.cs | 16 ----------- ...AspNetCoreDaprPubSubProviderContributor.cs | 6 ---- .../AbpAspNetCoreDaprSubscriptionRequest.cs | 8 ------ ...AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs | 11 -------- ...CoreDaprSubscriptionDefinitionConverter.cs | 25 ----------------- .../Dapr/AbpAspNetCoreDaprModule.cs | 12 -------- .../FodyWeavers.xml | 0 .../FodyWeavers.xsd | 0 ...o.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj} | 3 +- .../AbpAspNetCoreMvcDaprEventBusModule.cs} | 18 ++++++------ .../AbpAspNetCoreMvcDaprEventBusOptions.cs | 11 ++++++++ .../AbpAspNetCoreMvcDaprPubSubConsts.cs} | 4 +-- .../AbpAspNetCoreMvcDaprPubSubProvider.cs} | 28 +++++++++---------- ...MvcDaprPubSubProviderContributorContext.cs | 16 +++++++++++ .../AbpAspNetCoreMvcDaprPubSubController.cs} | 17 ++++++----- ...NetCoreMvcDaprPubSubProviderContributor.cs | 6 ++++ ...spNetCoreMvcDaprSubscriptionDefinition.cs} | 4 +-- ...AbpAspNetCoreMvcDaprSubscriptionRequest.cs | 8 ++++++ ...AspNetCoreMvcDaprPubSubJsonNamingPolicy.cs | 11 ++++++++ ...eMvcDaprSubscriptionDefinitionConverter.cs | 25 +++++++++++++++++ .../FodyWeavers.xml | 0 .../FodyWeavers.xsd | 0 .../Volo.Abp.AspNetCore.Mvc.Dapr.csproj} | 1 + .../Mvc/Dapr/AbpAspNetCoreMvcDaprModule.cs | 13 +++++++++ .../src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj | 5 ++-- nupkg/common.ps1 | 4 +-- 28 files changed, 133 insertions(+), 134 deletions(-) delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr.EventBus => Volo.Abp.AspNetCore.Mvc.Dapr.EventBus}/FodyWeavers.xml (100%) rename framework/src/{Volo.Abp.AspNetCore.Dapr.EventBus => Volo.Abp.AspNetCore.Mvc.Dapr.EventBus}/FodyWeavers.xsd (100%) rename framework/src/{Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj => Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj} (81%) rename framework/src/{Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs => Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusModule.cs} (61%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusOptions.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs => Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubConsts.cs} (58%) rename framework/src/{Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs => Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProvider.cs} (59%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProviderContributorContext.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs => Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprPubSubController.cs} (64%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/IAbpAspNetCoreMvcDaprPubSubProviderContributor.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs => Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionDefinition.cs} (52%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionRequest.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr => Volo.Abp.AspNetCore.Mvc.Dapr}/FodyWeavers.xml (100%) rename framework/src/{Volo.Abp.AspNetCore.Dapr => Volo.Abp.AspNetCore.Mvc.Dapr}/FodyWeavers.xsd (100%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj => Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj} (99%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/AbpAspNetCoreMvcDaprModule.cs diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index f6eba4386d..4ce47bdbc8 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -415,9 +415,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Dapr", "s EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Client.Dapr", "src\Volo.Abp.Http.Client.Dapr\Volo.Abp.Http.Client.Dapr.csproj", "{18B796D2-D45D-41AE-9A42-75C9B14B20DF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr", "src\Volo.Abp.AspNetCore.Dapr\Volo.Abp.AspNetCore.Dapr.csproj", "{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Dapr", "src\Volo.Abp.AspNetCore.Mvc.Dapr\Volo.Abp.AspNetCore.Mvc.Dapr.csproj", "{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr.EventBus", "src\Volo.Abp.AspNetCore.Dapr.EventBus\Volo.Abp.AspNetCore.Dapr.EventBus.csproj", "{B02EF042-C39E-45C4-A92D-BF7554E1889D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Dapr.EventBus", "src\Volo.Abp.AspNetCore.Mvc.Dapr.EventBus\Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj", "{B02EF042-C39E-45C4-A92D-BF7554E1889D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.DistributedLocking.Dapr", "src\Volo.Abp.DistributedLocking.Dapr\Volo.Abp.DistributedLocking.Dapr.csproj", "{CAE48068-233C-47A9-BEAB-DDF521730E7A}" EndProject diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs deleted file mode 100644 index be65464428..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.AspNetCore.Dapr; - -public class AbpAspNetCoreDaprEventBusOptions -{ - public List Contributors { get; } - - public AbpAspNetCoreDaprEventBusOptions() - { - Contributors = new List(); - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs deleted file mode 100644 index 93cb43b0bf..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Volo.Abp.AspNetCore.Dapr.Models; - -namespace Volo.Abp.AspNetCore.Dapr; - -public class AbpAspNetCoreDaprPubSubProviderContributorContext -{ - public IServiceProvider ServiceProvider { get; } - - public List Subscriptions { get; } - - public AbpAspNetCoreDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels) - { - ServiceProvider = serviceProvider; - Subscriptions = daprSubscriptionModels; - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs deleted file mode 100644 index da9f7564de..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Volo.Abp.AspNetCore.Dapr; - -public interface IAbpAspNetCoreDaprPubSubProviderContributor -{ - Task ContributeAsync(AbpAspNetCoreDaprPubSubProviderContributorContext context); -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs deleted file mode 100644 index 1dd88b1015..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Volo.Abp.AspNetCore.Dapr.Models; - -public class AbpAspNetCoreDaprSubscriptionRequest -{ - public string PubSubName { get; set; } - - public string Topic { get; set; } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs deleted file mode 100644 index f6d4605ff2..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Text.Json; - -namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; - -public class AbpAspNetCoreDaprPubSubJsonNamingPolicy : JsonNamingPolicy -{ - public override string ConvertName(string name) - { - return name.ToLower(); - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs deleted file mode 100644 index c0699ece43..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using Volo.Abp.AspNetCore.Dapr.Models; - -namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; - -public class AbpAspNetCoreDaprSubscriptionDefinitionConverter : JsonConverter -{ - private JsonSerializerOptions _writeJsonSerializerOptions; - - public override AbpAspNetCoreDaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - throw new NotSupportedException(); - } - - public override void Write(Utf8JsonWriter writer, AbpAspNetCoreDaprSubscriptionDefinition value, JsonSerializerOptions options) - { - _writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(new JsonSerializerOptions(options) - { - PropertyNamingPolicy = new AbpAspNetCoreDaprPubSubJsonNamingPolicy() - }, x => x == this); - - JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions); - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs deleted file mode 100644 index 1650efa667..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.Modularity; - -namespace Volo.Abp.AspNetCore.Dapr; - -[DependsOn( - typeof(AbpAspNetCoreMvcModule) -)] -public class AbpAspNetCoreDaprModule : AbpModule -{ - -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/FodyWeavers.xml similarity index 100% rename from framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/FodyWeavers.xml diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/FodyWeavers.xsd similarity index 100% rename from framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/FodyWeavers.xsd diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj similarity index 81% rename from framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj index 0c9280a27e..78b46cad27 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj @@ -11,7 +11,8 @@ - + + diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusModule.cs similarity index 61% rename from framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusModule.cs index b4fd636e76..333a5aae9a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusModule.cs @@ -1,18 +1,16 @@ using Microsoft.AspNetCore.Http.Json; -using Volo.Abp.AspNetCore.Dapr.SystemTextJson; +using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson; using Volo.Abp.EventBus.Dapr; -using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Modularity; -namespace Volo.Abp.AspNetCore.Dapr; +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus; [DependsOn( - typeof(AbpAspNetCoreDaprModule), - typeof(AbpEventBusDaprModule), - typeof(AbpJsonModule) - )] -public class AbpAspNetCoreDaprEventBusModule : AbpModule + typeof(AbpAspNetCoreMvcDaprModule), + typeof(AbpEventBusDaprModule) +)] +public class AbpAspNetCoreMvcDaprEventBusModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { @@ -20,12 +18,12 @@ public class AbpAspNetCoreDaprEventBusModule : AbpModule Configure(options => { - options.SerializerOptions.Converters.Add(new AbpAspNetCoreDaprSubscriptionDefinitionConverter()); + options.SerializerOptions.Converters.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter()); }); Configure(options => { - options.JsonSerializerOptions.Converters.Add(new AbpAspNetCoreDaprSubscriptionDefinitionConverter()); + options.JsonSerializerOptions.Converters.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter()); }); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusOptions.cs new file mode 100644 index 0000000000..02ca4c8e22 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusOptions.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus; + +public class AbpAspNetCoreMvcDaprEventBusOptions +{ + public List Contributors { get; } + + public AbpAspNetCoreMvcDaprEventBusOptions() + { + Contributors = new List(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubConsts.cs similarity index 58% rename from framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubConsts.cs index c0cfb9d5cc..e785f2e737 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubConsts.cs @@ -1,6 +1,6 @@ -namespace Volo.Abp.AspNetCore.Dapr; +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus; -public class AbpAspNetCoreDaprPubSubConsts +public class AbpAspNetCoreMvcDaprPubSubConsts { public const string DaprSubscribeUrl = "dapr/subscribe"; diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProvider.cs similarity index 59% rename from framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProvider.cs index 0affd70bba..e797bd2fc0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProvider.cs @@ -1,35 +1,35 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Volo.Abp.AspNetCore.Dapr.Models; +using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models; using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus; using Volo.Abp.EventBus.Dapr; using Volo.Abp.EventBus.Distributed; -namespace Volo.Abp.AspNetCore.Dapr; +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus; -public class AbpAspNetCoreDaprPubSubProvider : ITransientDependency +public class AbpAspNetCoreMvcDaprPubSubProvider : ITransientDependency { protected IServiceProvider ServiceProvider { get; } - protected AbpAspNetCoreDaprEventBusOptions AspNetCoreDaprEventBusOptions { get; } + protected AbpAspNetCoreMvcDaprEventBusOptions AspNetCoreMvcDaprEventBusOptions { get; } protected AbpDaprEventBusOptions DaprEventBusOptions { get; } protected AbpDistributedEventBusOptions DistributedEventBusOptions { get; } - public AbpAspNetCoreDaprPubSubProvider( + public AbpAspNetCoreMvcDaprPubSubProvider( IServiceProvider serviceProvider, - IOptions aspNetCoreDaprEventBusOptions, + IOptions aspNetCoreDaprEventBusOptions, IOptions daprEventBusOptions, IOptions distributedEventBusOptions) { ServiceProvider = serviceProvider; - AspNetCoreDaprEventBusOptions = aspNetCoreDaprEventBusOptions.Value; + AspNetCoreMvcDaprEventBusOptions = aspNetCoreDaprEventBusOptions.Value; DaprEventBusOptions = daprEventBusOptions.Value; DistributedEventBusOptions = distributedEventBusOptions.Value; } - public virtual async Task> GetSubscriptionsAsync() + public virtual async Task> GetSubscriptionsAsync() { - var subscriptions = new List(); + var subscriptions = new List(); foreach (var handler in DistributedEventBusOptions.Handlers) { foreach (var @interface in handler.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDistributedEventHandler<>))) @@ -37,21 +37,21 @@ public class AbpAspNetCoreDaprPubSubProvider : ITransientDependency var eventType = @interface.GetGenericArguments()[0]; var eventName = EventNameAttribute.GetNameOrDefault(eventType); - subscriptions.Add(new AbpAspNetCoreDaprSubscriptionDefinition() + subscriptions.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinition() { PubSubName = DaprEventBusOptions.PubSubName, Topic = eventName, - Route = AbpAspNetCoreDaprPubSubConsts.DaprEventCallbackUrl + Route = AbpAspNetCoreMvcDaprPubSubConsts.DaprEventCallbackUrl }); } } - if (AspNetCoreDaprEventBusOptions.Contributors.Any()) + if (AspNetCoreMvcDaprEventBusOptions.Contributors.Any()) { using (var scope = ServiceProvider.CreateScope()) { - var context = new AbpAspNetCoreDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions); - foreach (var contributor in AspNetCoreDaprEventBusOptions.Contributors) + var context = new AbpAspNetCoreMvcDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions); + foreach (var contributor in AspNetCoreMvcDaprEventBusOptions.Contributors) { await contributor.ContributeAsync(context); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProviderContributorContext.cs new file mode 100644 index 0000000000..564b541dec --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProviderContributorContext.cs @@ -0,0 +1,16 @@ +using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models; + +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus; + +public class AbpAspNetCoreMvcDaprPubSubProviderContributorContext +{ + public IServiceProvider ServiceProvider { get; } + + public List Subscriptions { get; } + + public AbpAspNetCoreMvcDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels) + { + ServiceProvider = serviceProvider; + Subscriptions = daprSubscriptionModels; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprPubSubController.cs similarity index 64% rename from framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprPubSubController.cs index e2440d90ce..c97e793b53 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprPubSubController.cs @@ -2,28 +2,27 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Volo.Abp.AspNetCore.Dapr.Models; -using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models; using Volo.Abp.Dapr; using Volo.Abp.EventBus.Dapr; -namespace Volo.Abp.AspNetCore.Dapr.Controllers; +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Controllers; [Area("abp")] [RemoteService(Name = "abp")] -public class AbpAspNetCoreDaprPubSubController : AbpController +public class AbpAspNetCoreMvcDaprPubSubController : AbpController { - [HttpGet(AbpAspNetCoreDaprPubSubConsts.DaprSubscribeUrl)] - public virtual async Task> SubscribeAsync() + [HttpGet(AbpAspNetCoreMvcDaprPubSubConsts.DaprSubscribeUrl)] + public virtual async Task> SubscribeAsync() { - return await HttpContext.RequestServices.GetRequiredService().GetSubscriptionsAsync(); + return await HttpContext.RequestServices.GetRequiredService().GetSubscriptionsAsync(); } - [HttpPost(AbpAspNetCoreDaprPubSubConsts.DaprEventCallbackUrl)] + [HttpPost(AbpAspNetCoreMvcDaprPubSubConsts.DaprEventCallbackUrl)] public virtual async Task EventsAsync() { var bodyJsonDocument = await JsonDocument.ParseAsync(HttpContext.Request.Body); - var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(), + var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(), HttpContext.RequestServices.GetRequiredService>().Value.JsonSerializerOptions); var distributedEventBus = HttpContext.RequestServices.GetRequiredService(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/IAbpAspNetCoreMvcDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/IAbpAspNetCoreMvcDaprPubSubProviderContributor.cs new file mode 100644 index 0000000000..87047cd7ec --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/IAbpAspNetCoreMvcDaprPubSubProviderContributor.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus; + +public interface IAbpAspNetCoreMvcDaprPubSubProviderContributor +{ + Task ContributeAsync(AbpAspNetCoreMvcDaprPubSubProviderContributorContext context); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionDefinition.cs similarity index 52% rename from framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionDefinition.cs index 414a69fbf1..287e78e01a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionDefinition.cs @@ -1,6 +1,6 @@ -namespace Volo.Abp.AspNetCore.Dapr.Models; +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models; -public class AbpAspNetCoreDaprSubscriptionDefinition +public class AbpAspNetCoreMvcDaprSubscriptionDefinition { public string PubSubName { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionRequest.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionRequest.cs new file mode 100644 index 0000000000..46c04b5a44 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionRequest.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models; + +public class AbpAspNetCoreMvcDaprSubscriptionRequest +{ + public string PubSubName { get; set; } + + public string Topic { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy.cs new file mode 100644 index 0000000000..0aa6bd4f7c --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy.cs @@ -0,0 +1,11 @@ +using System.Text.Json; + +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson; + +public class AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy : JsonNamingPolicy +{ + public override string ConvertName(string name) + { + return name.ToLower(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter.cs new file mode 100644 index 0000000000..fa26d35ca6 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter.cs @@ -0,0 +1,25 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models; + +namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson; + +public class AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter : JsonConverter +{ + private JsonSerializerOptions _writeJsonSerializerOptions; + + public override AbpAspNetCoreMvcDaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + throw new NotSupportedException(); + } + + public override void Write(Utf8JsonWriter writer, AbpAspNetCoreMvcDaprSubscriptionDefinition value, JsonSerializerOptions options) + { + _writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(new JsonSerializerOptions(options) + { + PropertyNamingPolicy = new AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy() + }, x => x == this); + + JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/FodyWeavers.xml similarity index 100% rename from framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/FodyWeavers.xml diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/FodyWeavers.xsd similarity index 100% rename from framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/FodyWeavers.xsd diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj similarity index 99% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj index 51c2a097b9..d792a30b24 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj @@ -18,4 +18,5 @@ + diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/AbpAspNetCoreMvcDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/AbpAspNetCoreMvcDaprModule.cs new file mode 100644 index 0000000000..f8ba3fcfc2 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/AbpAspNetCoreMvcDaprModule.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.Dapr; + +[DependsOn( + typeof(AbpAspNetCoreMvcModule), + typeof(AbpDaprModule) +)] +public class AbpAspNetCoreMvcDaprModule : AbpModule +{ + +} diff --git a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj index 8c8b53ed91..d3a8651086 100644 --- a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj +++ b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj @@ -2,7 +2,7 @@ - + net6.0 enable @@ -11,12 +11,11 @@ - - + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index 65e2d46324..6762cbce07 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -99,8 +99,8 @@ $projects = ( "framework/src/Volo.Abp.AspNetCore.Authentication.OAuth", "framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect", "framework/src/Volo.Abp.AspNetCore", - "framework/src/Volo.Abp.AspNetCore.Dapr", - "framework/src/Volo.Abp.AspNetCore.Dapr.EventBus", + "framework/src/Volo.Abp.AspNetCore.Mvc.Dapr", + "framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus", "framework/src/Volo.Abp.AspNetCore.Components", "framework/src/Volo.Abp.AspNetCore.Components.Server", "framework/src/Volo.Abp.AspNetCore.Components.Web", From 6829794792ecb984f8b0997e64a1a1206ccfdc62 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 22 Aug 2022 17:05:01 +0800 Subject: [PATCH 20/20] Remove AbpDaprClientOptions --- .../Http/Client/Dapr/AbpDaprClientOptions.cs | 18 ------------------ .../Client/Dapr/AbpHttpClientDaprModule.cs | 8 +++----- 2 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs deleted file mode 100644 index e6fa2d35dd..0000000000 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; - -namespace Volo.Abp.Http.Client.Dapr; - -public class AbpDaprClientOptions -{ - public Action DaprHttpClientBuilderAction { get; set; } - - public AbpDaprClientOptions() - { - DaprHttpClientBuilderAction = DefaultDaprHttpClientBuilder; - } - - private void DefaultDaprHttpClientBuilder(string serviceName, IHttpClientBuilder clientBuilder) - { - clientBuilder.AddHttpMessageHandler(); - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs index 374fca198e..18a509d3ff 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs @@ -9,16 +9,14 @@ namespace Volo.Abp.Http.Client.Dapr; typeof(AbpDaprModule) )] public class AbpHttpClientDaprModule : AbpModule -{ - public override void ConfigureServices(ServiceConfigurationContext context) +{ + public override void PreConfigureServices(ServiceConfigurationContext context) { - var daprClientOptions = context.Services.ExecutePreConfiguredActions(); - PreConfigure(options => { options.ProxyClientBuildActions.Add((_, clientBuilder) => { - daprClientOptions.DaprHttpClientBuilderAction(_, clientBuilder); + clientBuilder.AddHttpMessageHandler(); }); }); }