From 549b32a08fdcbda45bdb03ead91f1aaf6c698be4 Mon Sep 17 00:00:00 2001
From: cKey <35512826+colinin@users.noreply.github.com>
Date: Thu, 23 Dec 2021 18:01:28 +0800
Subject: [PATCH] fix(dapr): example Remove redundant remote service
configuration options
---
aspnet-core/LINGYUN.MicroService.Common.sln | 7 ++++
.../FodyWeavers.xml | 3 ++
.../FodyWeavers.xsd | 30 +++++++++++++++++
....Abp.Dapr.Actors.AspNetCore.Wrapper.csproj | 16 ++++++++++
.../AbpDaprActorsAspNetCoreWrapperModule.cs | 20 ++++++++++++
.../LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj | 4 ---
.../AbpDaprActorsAspNetCoreModule.cs | 9 +-----
.../Abp/Dapr/Actors/AbpDaprActorsModule.cs | 1 -
.../Actors/AbpDaprRemoteServiceOptions.cs | 14 --------
.../DynamicDaprActorProxyInterceptor.cs | 15 +++++----
.../Abp/Dapr/Client/AbpDaprClientModule.cs | 2 --
.../Client/AbpDaprRemoteServiceOptions.cs | 12 -------
.../Client/DaprRemoteServiceConfiguration.cs | 30 -----------------
...aprRemoteServiceConfigurationDictionary.cs | 32 -------------------
...aprRemoteServiceConfigurationExtensions.cs | 25 +++++++++++++++
.../DaprApiDescriptionFinder.cs | 10 +++---
.../DynamicDaprClientProxyInterceptor.cs | 7 ++--
.../DynamicDaprProxyInterceptorClientProxy.cs | 15 ++++-----
...lectionDynamicDaprClientProxyExtensions.cs | 11 ++++---
19 files changed, 131 insertions(+), 132 deletions(-)
create mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/FodyWeavers.xml
create mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/FodyWeavers.xsd
create mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj
create mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN/Abp/Dapr/Actors/AspNetCore/Wrapper/AbpDaprActorsAspNetCoreWrapperModule.cs
delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/AbpDaprRemoteServiceOptions.cs
delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprRemoteServiceOptions.cs
delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfiguration.cs
delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfigurationDictionary.cs
create mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfigurationExtensions.cs
diff --git a/aspnet-core/LINGYUN.MicroService.Common.sln b/aspnet-core/LINGYUN.MicroService.Common.sln
index c07a7616f..e764be7e7 100644
--- a/aspnet-core/LINGYUN.MicroService.Common.sln
+++ b/aspnet-core/LINGYUN.MicroService.Common.sln
@@ -230,6 +230,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "hangfire", "hangfire", "{3A
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Hangfire.Dashboard", "modules\common\LINGYUN.Abp.Hangfire.Dashboard\LINGYUN.Abp.Hangfire.Dashboard.csproj", "{FF518E10-C9AB-440C-8E8D-9CFF67A926AC}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper", "modules\dapr\LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper\LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj", "{49E0B90B-8635-43D0-B0AB-9D484CAE68B5}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -592,6 +594,10 @@ Global
{FF518E10-C9AB-440C-8E8D-9CFF67A926AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF518E10-C9AB-440C-8E8D-9CFF67A926AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF518E10-C9AB-440C-8E8D-9CFF67A926AC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {49E0B90B-8635-43D0-B0AB-9D484CAE68B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {49E0B90B-8635-43D0-B0AB-9D484CAE68B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {49E0B90B-8635-43D0-B0AB-9D484CAE68B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {49E0B90B-8635-43D0-B0AB-9D484CAE68B5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -706,6 +712,7 @@ Global
{E31F0421-3DFD-4225-A96B-38D603FB504D} = {38E21687-5F19-42C9-9D11-4B1D2EF64EDB}
{AC5F30A4-284E-4C57-A2E6-B1AD0D5AF7C9} = {38E21687-5F19-42C9-9D11-4B1D2EF64EDB}
{FF518E10-C9AB-440C-8E8D-9CFF67A926AC} = {3A0784A6-AFBF-406F-B79E-9505EB100445}
+ {49E0B90B-8635-43D0-B0AB-9D484CAE68B5} = {7FDFB22F-1BFF-4E05-9427-78B7A8461D50}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06C707C6-02C0-411A-AD3B-2D0E13787CB8}
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/FodyWeavers.xml b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/FodyWeavers.xml
new file mode 100644
index 000000000..1715698cc
--- /dev/null
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/FodyWeavers.xsd b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/FodyWeavers.xsd
new file mode 100644
index 000000000..11da52550
--- /dev/null
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/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/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj
new file mode 100644
index 000000000..c2ab11636
--- /dev/null
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ net6.0
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN/Abp/Dapr/Actors/AspNetCore/Wrapper/AbpDaprActorsAspNetCoreWrapperModule.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN/Abp/Dapr/Actors/AspNetCore/Wrapper/AbpDaprActorsAspNetCoreWrapperModule.cs
new file mode 100644
index 000000000..cb24bb8f5
--- /dev/null
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN/Abp/Dapr/Actors/AspNetCore/Wrapper/AbpDaprActorsAspNetCoreWrapperModule.cs
@@ -0,0 +1,20 @@
+using Dapr.Actors;
+using LINGYUN.Abp.Wrapper;
+using Volo.Abp.Modularity;
+
+namespace LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper
+{
+ [DependsOn(
+ typeof(AbpDaprActorsAspNetCoreModule),
+ typeof(AbpWrapperModule))]
+ public class AbpDaprActorsAspNetCoreWrapperModule : AbpModule
+ {
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options.IgnoredInterfaces.TryAdd();
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj
index 055846c9b..b965e7a6c 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj
@@ -13,8 +13,4 @@
-
-
-
-
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN/Abp/Dapr/Actors/AspNetCore/AbpDaprActorsAspNetCoreModule.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN/Abp/Dapr/Actors/AspNetCore/AbpDaprActorsAspNetCoreModule.cs
index 427a1c056..4d7c86251 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN/Abp/Dapr/Actors/AspNetCore/AbpDaprActorsAspNetCoreModule.cs
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN/Abp/Dapr/Actors/AspNetCore/AbpDaprActorsAspNetCoreModule.cs
@@ -1,6 +1,5 @@
using Dapr.Actors;
using Dapr.Actors.Runtime;
-using LINGYUN.Abp.Wrapper;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
@@ -12,8 +11,7 @@ using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Dapr.Actors.AspNetCore
{
[DependsOn(
- typeof(AbpAspNetCoreModule),
- typeof(AbpWrapperModule))]
+ typeof(AbpAspNetCoreModule))]
public class AbpDaprActorsAspNetCoreModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
@@ -30,11 +28,6 @@ namespace LINGYUN.Abp.Dapr.Actors.AspNetCore
endpointContext.Endpoints.MapActorsHandlers();
});
});
-
- Configure(options =>
- {
- options.IgnoredInterfaces.TryAdd();
- });
}
private static void AddDefinitionActor(IServiceCollection services)
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/AbpDaprActorsModule.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/AbpDaprActorsModule.cs
index 9a777a844..fcdaefda4 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/AbpDaprActorsModule.cs
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/AbpDaprActorsModule.cs
@@ -17,7 +17,6 @@ namespace LINGYUN.Abp.Dapr.Actors
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
- Configure(configuration);
context.Services.AddHttpClient(DaprHttpClient);
}
}
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/AbpDaprRemoteServiceOptions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/AbpDaprRemoteServiceOptions.cs
deleted file mode 100644
index 0dc9942fb..000000000
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/AbpDaprRemoteServiceOptions.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using Volo.Abp.Http.Client;
-
-namespace LINGYUN.Abp.Dapr.Actors
-{
- public class AbpDaprRemoteServiceOptions
- {
- public RemoteServiceConfigurationDictionary RemoteServices { get; set; }
-
- public AbpDaprRemoteServiceOptions()
- {
- RemoteServices = new RemoteServiceConfigurationDictionary();
- }
- }
-}
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/DynamicProxying/DynamicDaprActorProxyInterceptor.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/DynamicProxying/DynamicDaprActorProxyInterceptor.cs
index 99a10737d..1f99521a3 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/DynamicProxying/DynamicDaprActorProxyInterceptor.cs
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN/Abp/Dapr/Actors/DynamicProxying/DynamicDaprActorProxyInterceptor.cs
@@ -13,6 +13,7 @@ using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.DynamicProxy;
using Volo.Abp.Http;
+using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.Authentication;
using Volo.Abp.Http.Client.Proxying;
using Volo.Abp.MultiTenancy;
@@ -24,25 +25,25 @@ namespace LINGYUN.Abp.Dapr.Actors.DynamicProxying
where TService: IActor
{
protected ICurrentTenant CurrentTenant { get; }
- protected AbpDaprRemoteServiceOptions DaprServiceOptions { get; }
protected AbpDaprActorProxyOptions DaprActorProxyOptions { get; }
protected IProxyHttpClientFactory HttpClientFactory { get; }
- protected IRemoteServiceHttpClientAuthenticator ClientAuthenticator { get; }
+ protected IRemoteServiceHttpClientAuthenticator ClientAuthenticator { get; }
+ protected IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; }
public ILogger> Logger { get; set; }
public DynamicDaprActorProxyInterceptor(
IOptions daprActorProxyOptions,
- IOptionsSnapshot daprActorOptions,
IProxyHttpClientFactory httpClientFactory,
IRemoteServiceHttpClientAuthenticator clientAuthenticator,
+ IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider,
ICurrentTenant currentTenant)
{
CurrentTenant = currentTenant;
HttpClientFactory = httpClientFactory;
ClientAuthenticator = clientAuthenticator;
- DaprActorProxyOptions = daprActorProxyOptions.Value;
- DaprServiceOptions = daprActorOptions.Value;
-
+ DaprActorProxyOptions = daprActorProxyOptions.Value;
+ RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider;
+
Logger = NullLogger>.Instance;
}
@@ -68,7 +69,7 @@ namespace LINGYUN.Abp.Dapr.Actors.DynamicProxying
{
// 获取Actor配置
var actorProxyConfig = DaprActorProxyOptions.ActorProxies.GetOrDefault(typeof(TService)) ?? throw new AbpException($"Could not get DynamicDaprActorProxyConfig for {typeof(TService).FullName}.");
- var remoteServiceConfig = DaprServiceOptions.RemoteServices.GetConfigurationOrDefault(actorProxyConfig.RemoteServiceName);
+ var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync(actorProxyConfig.RemoteServiceName);
// Actors的定义太多, 可以考虑使用默认的 BaseUrl 作为远程地址
if (remoteServiceConfig.BaseUrl.IsNullOrWhiteSpace())
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientModule.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientModule.cs
index 717972507..7777c42ec 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientModule.cs
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientModule.cs
@@ -17,8 +17,6 @@ namespace LINGYUN.Abp.Dapr.Client
public override void ConfigureServices(ServiceConfigurationContext context)
{
- var configuration = context.Services.GetConfiguration();
- Configure(configuration);
context.Services.AddHttpClient(DaprHttpClient);
context.Services.AddTransient(typeof(DynamicDaprProxyInterceptorClientProxy<>));
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprRemoteServiceOptions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprRemoteServiceOptions.cs
deleted file mode 100644
index d4ce4594c..000000000
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprRemoteServiceOptions.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace LINGYUN.Abp.Dapr.Client
-{
- public class AbpDaprRemoteServiceOptions
- {
- public DaprRemoteServiceConfigurationDictionary RemoteServices { get; set; }
-
- public AbpDaprRemoteServiceOptions()
- {
- RemoteServices = new DaprRemoteServiceConfigurationDictionary();
- }
- }
-}
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfiguration.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfiguration.cs
deleted file mode 100644
index fbc680c7c..000000000
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfiguration.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System.Collections.Generic;
-using Volo.Abp.Http.Client;
-
-namespace LINGYUN.Abp.Dapr.Client
-{
- public class DaprRemoteServiceConfiguration : RemoteServiceConfiguration
- {
- ///
- /// Base AppId.
- ///
- public string AppId
- {
- get => this.GetOrDefault(nameof(AppId));
- set => this[nameof(AppId)] = value;
- }
-
- public DaprRemoteServiceConfiguration()
- {
- }
-
- public DaprRemoteServiceConfiguration(
- string appId,
- string baseUil,
- string version)
- : base(baseUil, version)
- {
- this[nameof(AppId)] = appId;
- }
- }
-}
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfigurationDictionary.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfigurationDictionary.cs
deleted file mode 100644
index f9d6f478e..000000000
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfigurationDictionary.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using JetBrains.Annotations;
-using System.Collections.Generic;
-using Volo.Abp;
-
-namespace LINGYUN.Abp.Dapr.Client
-{
- public class DaprRemoteServiceConfigurationDictionary : Dictionary
- {
- public const string DefaultName = "Default";
-
- public DaprRemoteServiceConfiguration Default
- {
- get => this.GetOrDefault(DefaultName);
- set => this[DefaultName] = value;
- }
-
- [NotNull]
- public DaprRemoteServiceConfiguration GetConfigurationOrDefault(string name)
- {
- return this.GetOrDefault(name)
- ?? Default
- ?? throw new AbpException($"Dapr remote service '{name}' was not found and there is no default configuration.");
- }
-
- [CanBeNull]
- public DaprRemoteServiceConfiguration GetConfigurationOrDefaultOrNull(string name)
- {
- return this.GetOrDefault(name)
- ?? Default;
- }
- }
-}
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfigurationExtensions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfigurationExtensions.cs
new file mode 100644
index 000000000..4a5f9f3aa
--- /dev/null
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DaprRemoteServiceConfigurationExtensions.cs
@@ -0,0 +1,25 @@
+using JetBrains.Annotations;
+using System.Collections.Generic;
+using Volo.Abp;
+using Volo.Abp.Http.Client;
+
+namespace LINGYUN.Abp.Dapr.Client;
+
+public static class DaprRemoteServiceConfigurationExtensions
+{
+ public const string AppId = "AppId";
+
+ [NotNull]
+ public static string GetAppId([NotNull] this RemoteServiceConfiguration configuration)
+ {
+ Check.NotNullOrEmpty(configuration, nameof(configuration));
+
+ return configuration.GetOrDefault(AppId) ?? throw new AbpException($"Could not get AppId for RemoteServices Configuration.");
+ }
+
+ public static RemoteServiceConfiguration SetAppId([NotNull] this RemoteServiceConfiguration configuration, [CanBeNull] string value)
+ {
+ configuration[AppId] = value;
+ return configuration;
+ }
+}
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DaprApiDescriptionFinder.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DaprApiDescriptionFinder.cs
index 10320021e..9eac6c797 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DaprApiDescriptionFinder.cs
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DaprApiDescriptionFinder.cs
@@ -22,6 +22,11 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
{
public class DaprApiDescriptionFinder : IDaprApiDescriptionFinder, ITransientDependency
{
+ public static JsonSerializerOptions DeserializeOptions = new JsonSerializerOptions
+ {
+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase
+ };
+
public ICancellationTokenProvider CancellationTokenProvider { get; set; }
protected IApiDescriptionCache Cache { get; }
protected AbpCorrelationIdOptions AbpCorrelationIdOptions { get; }
@@ -112,10 +117,7 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
var content = await response.Content.ReadAsStringAsync();
- var result = JsonSerializer.Deserialize(content, new JsonSerializerOptions
- {
- PropertyNamingPolicy = JsonNamingPolicy.CamelCase
- });
+ var result = JsonSerializer.Deserialize(content, DeserializeOptions);
return result;
}
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprClientProxyInterceptor.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprClientProxyInterceptor.cs
index 4e27efae0..baea6e563 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprClientProxyInterceptor.cs
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprClientProxyInterceptor.cs
@@ -29,7 +29,6 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
public ILogger> Logger { get; set; }
protected DynamicDaprProxyInterceptorClientProxy InterceptorClientProxy { get; }
- protected AbpDaprRemoteServiceOptions AbpRemoteServiceOptions { get; }
protected AbpDaprClientProxyOptions ClientProxyOptions { get; }
protected IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; }
protected IDaprApiDescriptionFinder ApiDescriptionFinder { get; }
@@ -37,7 +36,6 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
public DynamicDaprClientProxyInterceptor(
DynamicDaprProxyInterceptorClientProxy interceptorClientProxy,
IOptions clientProxyOptions,
- IOptions remoteServiceOptions,
IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider,
IDaprApiDescriptionFinder apiDescriptionFinder)
{
@@ -45,7 +43,6 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider;
ApiDescriptionFinder = apiDescriptionFinder;
ClientProxyOptions = clientProxyOptions.Value;
- AbpRemoteServiceOptions = remoteServiceOptions.Value;
Logger = NullLogger>.Instance;
}
@@ -76,11 +73,11 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
{
var clientConfig = ClientProxyOptions.DaprClientProxies.GetOrDefault(typeof(TService)) ??
throw new AbpException($"Could not get DynamicDaprClientProxyConfig for {typeof(TService).FullName}.");
- var remoteServiceConfig = AbpRemoteServiceOptions.RemoteServices.GetConfigurationOrDefault(clientConfig.RemoteServiceName);
+ var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync(clientConfig.RemoteServiceName);
return await ApiDescriptionFinder.FindActionAsync(
clientConfig.RemoteServiceName,
- remoteServiceConfig.AppId,
+ remoteServiceConfig.GetAppId(),
typeof(TService),
invocation.Method
);
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprProxyInterceptorClientProxy.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprProxyInterceptorClientProxy.cs
index f43a14cf6..80d7e550f 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprProxyInterceptorClientProxy.cs
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprProxyInterceptorClientProxy.cs
@@ -13,7 +13,6 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
{
public class DynamicDaprProxyInterceptorClientProxy : ClientProxyBase
{
- protected IOptions DaprRemoteServiceOptions => LazyServiceProvider.LazyGetRequiredService>();
protected IOptions DaprClientProxyOptions => LazyServiceProvider.LazyGetRequiredService>();
protected IDaprClientFactory DaprClientFactory => LazyServiceProvider.LazyGetRequiredService();
@@ -64,28 +63,28 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
return JsonSerializer.Deserialize(stringContent);
}
- protected override Task GetConfiguredApiVersionAsync(ClientProxyRequestContext requestContext)
+ protected override async Task GetConfiguredApiVersionAsync(ClientProxyRequestContext requestContext)
{
var clientConfig = DaprClientProxyOptions.Value.DaprClientProxies.GetOrDefault(requestContext.ServiceType)
?? throw new AbpException($"Could not get DynamicDaprClientProxyConfig for {requestContext.ServiceType.FullName}.");
+ var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync(clientConfig.RemoteServiceName);
- var remoteServiceConfig = DaprRemoteServiceOptions.Value.RemoteServices.GetConfigurationOrDefaultOrNull(clientConfig.RemoteServiceName);
-
- return Task.FromResult(remoteServiceConfig?.Version);
+ return remoteServiceConfig?.Version;
}
private async Task MakeRequestAsync(ClientProxyRequestContext requestContext)
{
var clientConfig = DaprClientProxyOptions.Value.DaprClientProxies.GetOrDefault(requestContext.ServiceType) ?? throw new AbpException($"Could not get DaprClientProxyConfig for {requestContext.ServiceType.FullName}.");
- var remoteServiceConfig = DaprRemoteServiceOptions.Value.RemoteServices.GetConfigurationOrDefault(clientConfig.RemoteServiceName);
+ var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync(clientConfig.RemoteServiceName);
+ var appId = remoteServiceConfig.GetAppId();
var apiVersion = await GetApiVersionInfoAsync(requestContext);
var methodName = await GetUrlWithParametersAsync(requestContext, apiVersion);
// See: https://docs.dapr.io/reference/api/service_invocation_api/#examples
var daprClient = DaprClientFactory.CreateClient(clientConfig.RemoteServiceName);
var requestMessage = daprClient.CreateInvokeMethodRequest(
requestContext.Action.GetHttpMethod(),
- remoteServiceConfig.AppId,
+ appId,
methodName);
requestMessage.Content = await ClientProxyRequestPayloadBuilder.BuildContentAsync(
requestContext.Action,
@@ -119,7 +118,7 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
// 增加一个可配置的请求消息
foreach (var clientRequestAction in DaprClientProxyOptions.Value.ProxyRequestActions)
{
- clientRequestAction(remoteServiceConfig.AppId, requestMessage);
+ clientRequestAction(appId, requestMessage);
}
var response = await daprClient.InvokeMethodWithResponseAsync(requestMessage, GetCancellationToken(requestContext.Arguments));
diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs
index a871e60ef..c54581015 100644
--- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs
+++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs
@@ -9,6 +9,7 @@ using System.Linq;
using System.Reflection;
using Volo.Abp;
using Volo.Abp.Castle.DynamicProxy;
+using Volo.Abp.Http.Client;
using Volo.Abp.Json.SystemTextJson;
using Volo.Abp.Validation;
@@ -23,7 +24,7 @@ namespace Microsoft.Extensions.DependencyInjection
public static IServiceCollection AddDaprClientProxies(
[NotNull] this IServiceCollection services,
[NotNull] Assembly assembly,
- [NotNull] string remoteServiceConfigurationName = DaprRemoteServiceConfigurationDictionary.DefaultName,
+ [NotNull] string remoteServiceConfigurationName = RemoteServiceConfigurationDictionary.DefaultName,
bool asDefaultServices = true)
{
Check.NotNull(services, nameof(assembly));
@@ -44,7 +45,7 @@ namespace Microsoft.Extensions.DependencyInjection
public static IServiceCollection AddDaprClientProxy(
[NotNull] this IServiceCollection services,
- [NotNull] string remoteServiceConfigurationName = DaprRemoteServiceConfigurationDictionary.DefaultName,
+ [NotNull] string remoteServiceConfigurationName = RemoteServiceConfigurationDictionary.DefaultName,
bool asDefaultService = true)
{
return services.AddDaprClientProxy(
@@ -57,7 +58,7 @@ namespace Microsoft.Extensions.DependencyInjection
public static IServiceCollection AddDaprClientProxy(
[NotNull] this IServiceCollection services,
[NotNull] Type type,
- [NotNull] string remoteServiceConfigurationName = DaprRemoteServiceConfigurationDictionary.DefaultName,
+ [NotNull] string remoteServiceConfigurationName = RemoteServiceConfigurationDictionary.DefaultName,
bool asDefaultService = true)
{
Check.NotNull(services, nameof(services));
@@ -114,7 +115,7 @@ namespace Microsoft.Extensions.DependencyInjection
private static IServiceCollection AddDaprClientFactory(
[NotNull] this IServiceCollection services,
- [NotNull] string remoteServiceConfigurationName = DaprRemoteServiceConfigurationDictionary.DefaultName)
+ [NotNull] string remoteServiceConfigurationName = RemoteServiceConfigurationDictionary.DefaultName)
{
var preOptions = services.ExecutePreConfiguredActions();
@@ -129,7 +130,7 @@ namespace Microsoft.Extensions.DependencyInjection
var jsonOptions = provider.GetRequiredService>().Value;
builder.UseJsonSerializationOptions(jsonOptions.JsonSerializerOptions);
- var options = provider.GetRequiredService>().Value;
+ var options = provider.GetRequiredService>().Value;
builder.UseHttpEndpoint(
options.RemoteServices
.GetConfigurationOrDefault(remoteServiceConfigurationName).BaseUrl);