Browse Source

Merge pull request #256 from colinin/4.3

Improved DaprClient to accommodate multiple remoteServices
pull/274/head
cKey 5 years ago
committed by GitHub
parent
commit
61d741556a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      aspnet-core/LINGYUN.MicroService.Common.sln
  2. 72
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/DaprClientBuilderExtensions.cs
  3. 21
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/DaprClientFactoryOptions.cs
  4. 17
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/DefaultDaprClientBuilder.cs
  5. 82
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/DefaultDaprClientFactory.cs
  6. 10
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/IDaprClientBuilder.cs
  7. 7
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/IDaprClientFactory.cs
  8. 22
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientBuilderOptions.cs
  9. 6
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientModule.cs
  10. 14
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientOptions.cs
  11. 21
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DaprApiDescriptionFinder.cs
  12. 12
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DaprClientProxy.cs
  13. 24
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprClientProxyInterceptor.cs
  14. 4
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/IDaprApiDescriptionFinder.cs
  15. 7
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/IDaprClientProxy.cs
  16. 161
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs
  17. 20
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/README.md
  18. 8
      aspnet-core/modules/dapr/README.md
  19. 18
      aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN.Abp.Dapr.AspNetCore.TestHost.csproj
  20. 39
      aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN/Abp/Dapr/AbpDaprAspNetCoreTestHostModule.cs
  21. 61
      aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN/Abp/Dapr/Actors/TestActor.cs
  22. 41
      aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN/Abp/Dapr/ServiceInvocation/TestAppService.cs
  23. 23
      aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/Program.cs
  24. 21
      aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/Properties/launchSettings.json
  25. 18
      aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/Startup.cs
  26. 34
      aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN.Abp.Dapr.Client.Tests.csproj
  27. 34
      aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN/Abp/Dapr/Client/Tests/AbpDaptClientTestBase.cs
  28. 33
      aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN/Abp/Dapr/Client/Tests/AbpDaptClientTestModule.cs
  29. 33
      aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN/Abp/Dapr/Client/Tests/TestAppServiceTests.cs
  30. 13
      aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN.Abp.Dapr.Tests.csproj
  31. 11
      aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN/Abp/Dapr/AbpDaprTestModule.cs
  32. 17
      aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN/Abp/Dapr/Actors/ITestActor.cs
  33. 14
      aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN/Abp/Dapr/ServiceInvocation/ITestAppService.cs

21
aspnet-core/LINGYUN.MicroService.Common.sln

@ -154,6 +154,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.RulesEngi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.NRules.Tests", "tests\LINGYUN.Abp.Rules.NRules.Tests\LINGYUN.Abp.Rules.NRules.Tests.csproj", "{EF03A0A7-A93E-4DEF-A33E-F5A82E995FBF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Dapr.Client.Tests", "tests\LINGYUN.Abp.Dapr.Client.Tests\LINGYUN.Abp.Dapr.Client.Tests.csproj", "{9403FC1F-9677-489F-A03A-0B456153EE86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Dapr.Tests", "tests\LINGYUN.Abp.Dapr.Tests\LINGYUN.Abp.Dapr.Tests.csproj", "{26E87199-F0AD-4B30-B0E4-080B12E6F8FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Dapr.AspNetCore.TestHost", "tests\LINGYUN.Abp.Dapr.AspNetCore.TestHost\LINGYUN.Abp.Dapr.AspNetCore.TestHost.csproj", "{8968EDAF-9F5C-4786-AF2A-D3928B70C3EC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -400,6 +406,18 @@ Global
{EF03A0A7-A93E-4DEF-A33E-F5A82E995FBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF03A0A7-A93E-4DEF-A33E-F5A82E995FBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF03A0A7-A93E-4DEF-A33E-F5A82E995FBF}.Release|Any CPU.Build.0 = Release|Any CPU
{9403FC1F-9677-489F-A03A-0B456153EE86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9403FC1F-9677-489F-A03A-0B456153EE86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9403FC1F-9677-489F-A03A-0B456153EE86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9403FC1F-9677-489F-A03A-0B456153EE86}.Release|Any CPU.Build.0 = Release|Any CPU
{26E87199-F0AD-4B30-B0E4-080B12E6F8FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26E87199-F0AD-4B30-B0E4-080B12E6F8FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26E87199-F0AD-4B30-B0E4-080B12E6F8FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26E87199-F0AD-4B30-B0E4-080B12E6F8FC}.Release|Any CPU.Build.0 = Release|Any CPU
{8968EDAF-9F5C-4786-AF2A-D3928B70C3EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8968EDAF-9F5C-4786-AF2A-D3928B70C3EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8968EDAF-9F5C-4786-AF2A-D3928B70C3EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8968EDAF-9F5C-4786-AF2A-D3928B70C3EC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -477,6 +495,9 @@ Global
{E861BE01-689D-4637-A5DC-E78E234F83FB} = {C8891F1A-E6E5-448A-B527-EBFA44D20808}
{CF253F0A-3A45-40EE-875F-0E57C8968C48} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
{EF03A0A7-A93E-4DEF-A33E-F5A82E995FBF} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
{9403FC1F-9677-489F-A03A-0B456153EE86} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
{26E87199-F0AD-4B30-B0E4-080B12E6F8FC} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
{8968EDAF-9F5C-4786-AF2A-D3928B70C3EC} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06C707C6-02C0-411A-AD3B-2D0E13787CB8}

72
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/DaprClientBuilderExtensions.cs

@ -0,0 +1,72 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System;
namespace Dapr.Client
{
public static class DaprClientBuilderExtensions
{
public static IDaprClientBuilder ConfigureDaprClient(this IDaprClientBuilder builder, Action<DaprClient> configureClient)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (configureClient == null)
{
throw new ArgumentNullException(nameof(configureClient));
}
builder.Services.Configure<DaprClientFactoryOptions>(builder.Name, options =>
{
options.DaprClientActions.Add(configureClient);
});
return builder;
}
public static IDaprClientBuilder ConfigureDaprClient(this IDaprClientBuilder builder, Action<DaprClientBuilder> configureBuilder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (configureBuilder == null)
{
throw new ArgumentNullException(nameof(configureBuilder));
}
builder.Services.Configure<DaprClientFactoryOptions>(builder.Name, options =>
{
options.DaprClientBuilderActions.Add(configureBuilder);
});
return builder;
}
public static IDaprClientBuilder ConfigureDaprClient(this IDaprClientBuilder builder, Action<IServiceProvider, DaprClientBuilder> configureClientBuilder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (configureClientBuilder == null)
{
throw new ArgumentNullException(nameof(configureClientBuilder));
}
builder.Services.AddTransient<IConfigureOptions<DaprClientFactoryOptions>>(services =>
{
return new ConfigureNamedOptions<DaprClientFactoryOptions>(builder.Name, (options) =>
{
options.DaprClientBuilderActions.Add(client => configureClientBuilder(services, client));
});
});
return builder;
}
}
}

21
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/DaprClientFactoryOptions.cs

@ -0,0 +1,21 @@
using Grpc.Net.Client;
using System;
using System.Collections.Generic;
using System.Text.Json;
namespace Dapr.Client
{
public class DaprClientFactoryOptions
{
public string DaprApiToken{ get; set; }
public string HttpEndpoint { get; set; }
public string GrpcEndpoint { get; set; }
public GrpcChannelOptions GrpcChannelOptions { get; set; }
public JsonSerializerOptions JsonSerializerOptions { get; set; }
public IList<Action<DaprClient>> DaprClientActions { get; } = new List<Action<DaprClient>>();
public IList<Action<DaprClientBuilder>> DaprClientBuilderActions { get; } = new List<Action<DaprClientBuilder>>();
public DaprClientFactoryOptions()
{
}
}
}

17
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/DefaultDaprClientBuilder.cs

@ -0,0 +1,17 @@
using Microsoft.Extensions.DependencyInjection;
namespace Dapr.Client
{
internal class DefaultDaprClientBuilder : IDaprClientBuilder
{
public DefaultDaprClientBuilder(IServiceCollection services, string name)
{
Services = services;
Name = name;
}
public string Name { get; }
public IServiceCollection Services { get; }
}
}

82
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/DefaultDaprClientFactory.cs

@ -0,0 +1,82 @@
using Microsoft.Extensions.Options;
using System;
using System.Collections.Concurrent;
using System.Threading;
namespace Dapr.Client
{
public class DefaultDaprClientFactory : IDaprClientFactory
{
private readonly IOptionsMonitor<DaprClientFactoryOptions> _optionsMonitor;
private readonly Func<string, Lazy<DaprClient>> _daprClientFactory;
internal readonly ConcurrentDictionary<string, Lazy<DaprClient>> _daprClients;
public DefaultDaprClientFactory(
IOptionsMonitor<DaprClientFactoryOptions> optionsMonitor)
{
_optionsMonitor = optionsMonitor ?? throw new ArgumentNullException(nameof(optionsMonitor));
_daprClients = new ConcurrentDictionary<string, Lazy<DaprClient>>();
_daprClientFactory = (name) =>
{
return new Lazy<DaprClient>(() =>
{
return InternalCreateDaprClient(name);
}, LazyThreadSafetyMode.ExecutionAndPublication);
};
}
public DaprClient CreateClient(string name)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
var client = _daprClients.GetOrAdd(name, _daprClientFactory).Value;
var options = _optionsMonitor.Get(name);
for (int i = 0; i < options.DaprClientActions.Count; i++)
{
options.DaprClientActions[i](client);
}
return client;
}
internal DaprClient InternalCreateDaprClient(string name)
{
var builder = new DaprClientBuilder();
var options = _optionsMonitor.Get(name);
if (!string.IsNullOrWhiteSpace(options.HttpEndpoint))
{
builder.UseHttpEndpoint(options.HttpEndpoint);
}
if (!string.IsNullOrWhiteSpace(options.GrpcEndpoint))
{
builder.UseGrpcEndpoint(options.GrpcEndpoint);
}
if (options.GrpcChannelOptions != null)
{
builder.UseGrpcChannelOptions(options.GrpcChannelOptions);
}
if (options.JsonSerializerOptions != null)
{
builder.UseJsonSerializationOptions(options.JsonSerializerOptions);
}
builder.UseDaprApiToken(options.DaprApiToken);
for (int i = 0; i < options.DaprClientBuilderActions.Count; i++)
{
options.DaprClientBuilderActions[i](builder);
}
return builder.Build();
}
}
}

10
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/IDaprClientBuilder.cs

@ -0,0 +1,10 @@
using Microsoft.Extensions.DependencyInjection;
namespace Dapr.Client
{
public interface IDaprClientBuilder
{
string Name { get; }
IServiceCollection Services { get; }
}
}

7
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Dapr/Client/IDaprClientFactory.cs

@ -0,0 +1,7 @@
namespace Dapr.Client
{
public interface IDaprClientFactory
{
DaprClient CreateClient(string name);
}
}

22
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientBuilderOptions.cs

@ -0,0 +1,22 @@
using Dapr.Client;
using System;
using System.Collections.Generic;
namespace LINGYUN.Abp.Dapr.Client
{
public class AbpDaprClientBuilderOptions
{
public List<Action<string, DaprClient>> ProxyClientActions { get; }
public List<Action<string, IServiceProvider, DaprClientBuilder>> ProxyClientBuildActions { get; }
internal HashSet<string> ConfiguredProxyClients { get; }
public AbpDaprClientBuilderOptions()
{
ConfiguredProxyClients = new HashSet<string>();
ProxyClientActions = new List<Action<string, DaprClient>>();
ProxyClientBuildActions = new List<Action<string, IServiceProvider, DaprClientBuilder>>();
}
}
}

6
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientModule.cs

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
@ -17,10 +18,7 @@ namespace LINGYUN.Abp.Dapr.Client
{
var configuration = context.Services.GetConfiguration();
Configure<AbpDaprRemoteServiceOptions>(configuration);
Configure<AbpDaprClientOptions>(configuration.GetSection("Dapr:Client"));
// DaprClient应该配置为单例的实现
context.Services.AddDaprClient();
context.Services.AddHttpClient(DaprHttpClient);
}
}
}

14
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/AbpDaprClientOptions.cs

@ -1,14 +0,0 @@
using Grpc.Net.Client;
namespace LINGYUN.Abp.Dapr.Client
{
public class AbpDaprClientOptions
{
public string GrpcEndpoint { get; set; }
public string HttpEndpoint { get; set; }
public GrpcChannelOptions GrpcChannelOptions { get; set; }
public AbpDaprClientOptions()
{
}
}
}

21
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DaprApiDescriptionFinder.cs

@ -27,15 +27,15 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
protected ICorrelationIdProvider CorrelationIdProvider { get; }
protected ICurrentTenant CurrentTenant { get; }
protected DaprClient DaprClient { get; }
protected IDaprClientFactory DaprClientFactory { get; }
public DaprApiDescriptionFinder(
DaprClient daprClient,
IDaprClientFactory daprClientFactory,
IApiDescriptionCache cache,
IOptions<AbpCorrelationIdOptions> abpCorrelationIdOptions,
ICorrelationIdProvider correlationIdProvider,
ICurrentTenant currentTenant)
{
DaprClient = daprClient;
DaprClientFactory = daprClientFactory;
Cache = cache;
AbpCorrelationIdOptions = abpCorrelationIdOptions.Value;
@ -44,9 +44,9 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
CancellationTokenProvider = NullCancellationTokenProvider.Instance;
}
public virtual async Task<ActionApiDescriptionModel> FindActionAsync(string appId, Type serviceType, MethodInfo method)
public virtual async Task<ActionApiDescriptionModel> FindActionAsync(string service, string appId, Type serviceType, MethodInfo method)
{
var apiDescription = await GetApiDescriptionAsync(appId);
var apiDescription = await GetApiDescriptionAsync(service, appId);
//TODO: Cache finding?
@ -88,18 +88,19 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
throw new AbpException($"Could not found remote action for method: {method} on the appId: {appId}");
}
public virtual async Task<ApplicationApiDescriptionModel> GetApiDescriptionAsync(string appId)
public virtual async Task<ApplicationApiDescriptionModel> GetApiDescriptionAsync(string service, string appId)
{
return await Cache.GetAsync(appId, () => GetApiDescriptionFromServerAsync(appId));
return await Cache.GetAsync(appId, () => GetApiDescriptionFromServerAsync(service, appId));
}
protected virtual async Task<ApplicationApiDescriptionModel> GetApiDescriptionFromServerAsync(string appId)
protected virtual async Task<ApplicationApiDescriptionModel> GetApiDescriptionFromServerAsync(string service, string appId)
{
var requestMessage = DaprClient.CreateInvokeMethodRequest(HttpMethod.Get, appId, "api/abp/api-definition");
var client = DaprClientFactory.CreateClient(service);
var requestMessage = client.CreateInvokeMethodRequest(HttpMethod.Get, appId, "api/abp/api-definition");
AddHeaders(requestMessage);
var response = await DaprClient.InvokeMethodWithResponseAsync(
var response = await client.InvokeMethodWithResponseAsync(
requestMessage,
CancellationTokenProvider.Token);

12
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DaprClientProxy.cs

@ -0,0 +1,12 @@
namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
{
public class DaprClientProxy<TRemoteService> : IDaprClientProxy<TRemoteService>
{
public TRemoteService Service { get; }
public DaprClientProxy(TRemoteService service)
{
Service = service;
}
}
}

24
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprClientProxyInterceptor.cs

@ -32,7 +32,7 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
{
protected static MethodInfo MakeRequestAndGetResultAsyncMethod { get; }
protected DaprClient DaprClient { get; }
protected IDaprClientFactory DaprClientFactory { get; }
protected ICancellationTokenProvider CancellationTokenProvider { get; }
protected ICorrelationIdProvider CorrelationIdProvider { get; }
protected ICurrentTenant CurrentTenant { get; }
@ -54,7 +54,7 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
}
public DynamicDaprClientProxyInterceptor(
DaprClient daprClient,
IDaprClientFactory daprClientFactory,
IOptions<AbpDaprClientProxyOptions> clientProxyOptions,
IOptionsSnapshot<AbpDaprRemoteServiceOptions> remoteServiceOptions,
IDaprApiDescriptionFinder apiDescriptionFinder,
@ -66,7 +66,7 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
IOptions<AbpCorrelationIdOptions> correlationIdOptions,
ICurrentTenant currentTenant)
{
DaprClient = daprClient;
DaprClientFactory = daprClientFactory;
CancellationTokenProvider = cancellationTokenProvider;
CorrelationIdProvider = correlationIdProvider;
CurrentTenant = currentTenant;
@ -145,6 +145,7 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
// 遵循远端 api/abp/api-definition
var action = await ApiDescriptionFinder.FindActionAsync(
clientConfig.RemoteServiceName,
remoteServiceConfig.AppId,
typeof(TService),
invocation.Method
@ -156,7 +157,8 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
// 需要合并端点作为dapr远程调用的方法名称
var methodName = UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary, apiVersion);
var requestMessage = DaprClient.CreateInvokeMethodRequest(
var daprClient = DaprClientFactory.CreateClient(clientConfig.RemoteServiceName);
var requestMessage = daprClient.CreateInvokeMethodRequest(
action.GetHttpMethod(),
remoteServiceConfig.AppId,
methodName);
@ -165,23 +167,25 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
AddHeaders(invocation, action, requestMessage, apiVersion);
var client = HttpClientFactory.Create(AbpDaprClientModule.DaprHttpClient);
var httpClient = HttpClientFactory.Create(AbpDaprClientModule.DaprHttpClient);
await ClientAuthenticator.Authenticate(
new RemoteServiceHttpClientAuthenticateContext(
client,
httpClient,
requestMessage,
remoteServiceConfig,
new RemoteServiceConfiguration(
remoteServiceConfig.BaseUrl,
remoteServiceConfig.Version),
clientConfig.RemoteServiceName
)
);
// 其他库可能将授权标头写入到HttpClient中
if (requestMessage.Headers.Authorization == null &&
client.DefaultRequestHeaders.Authorization != null)
httpClient.DefaultRequestHeaders.Authorization != null)
{
requestMessage.Headers.Authorization = client.DefaultRequestHeaders.Authorization;
requestMessage.Headers.Authorization = httpClient.DefaultRequestHeaders.Authorization;
}
var response = await DaprClient.InvokeMethodWithResponseAsync(requestMessage, GetCancellationToken());
var response = await daprClient.InvokeMethodWithResponseAsync(requestMessage, GetCancellationToken());
if (!response.IsSuccessStatusCode)
{

4
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/IDaprApiDescriptionFinder.cs

@ -7,8 +7,8 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
{
public interface IDaprApiDescriptionFinder
{
Task<ActionApiDescriptionModel> FindActionAsync(string appId, Type serviceType, MethodInfo invocationMethod);
Task<ActionApiDescriptionModel> FindActionAsync(string service, string appId, Type serviceType, MethodInfo invocationMethod);
Task<ApplicationApiDescriptionModel> GetApiDescriptionAsync(string appId);
Task<ApplicationApiDescriptionModel> GetApiDescriptionAsync(string service, string appId);
}
}

7
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/IDaprClientProxy.cs

@ -0,0 +1,7 @@
namespace LINGYUN.Abp.Dapr.Client.DynamicProxying
{
public interface IDaprClientProxy<out TRemoteService>
{
TRemoteService Service { get; }
}
}

161
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs

@ -10,7 +10,6 @@ using System.Linq;
using System.Reflection;
using Volo.Abp;
using Volo.Abp.Castle.DynamicProxy;
using Volo.Abp.Json.SystemTextJson;
using Volo.Abp.Validation;
namespace Microsoft.Extensions.DependencyInjection
@ -19,39 +18,97 @@ namespace Microsoft.Extensions.DependencyInjection
{
private static readonly ProxyGenerator ProxyGeneratorInstance = new ProxyGenerator();
#region Add DaprClient Builder
public static IServiceCollection AddDaprClient(
[NotNull] this IServiceCollection services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
services.AddLogging();
services.AddOptions();
services.TryAddSingleton<DefaultDaprClientFactory>();
services.TryAddSingleton<IDaprClientFactory>(serviceProvider => serviceProvider.GetRequiredService<DefaultDaprClientFactory>());
return services;
}
public static IDaprClientBuilder AddDaprClient(
[NotNull] this IServiceCollection services,
Action<DaprClientBuilder> setup = null)
string name)
{
Check.NotNull(services, nameof(services));
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
services.AddDaprClient();
services.TryAddSingleton(provider =>
return new DefaultDaprClientBuilder(services, name);
}
public static IDaprClientBuilder AddDaprClient(
[NotNull] this IServiceCollection services,
string name,
Action<DaprClientBuilder> configureClient)
{
if (services == null)
{
var abpSystemTextJsonSerializerOptions = provider.GetRequiredService<IOptions<AbpSystemTextJsonSerializerOptions>>().Value;
var abpDaprClientOptions = provider.GetRequiredService<IOptions<AbpDaprClientOptions>>().Value;
throw new ArgumentNullException(nameof(services));
}
var builder = new DaprClientBuilder()
.UseHttpEndpoint(abpDaprClientOptions.HttpEndpoint)
.UseJsonSerializationOptions(abpSystemTextJsonSerializerOptions.JsonSerializerOptions);
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (!abpDaprClientOptions.GrpcEndpoint.IsNullOrWhiteSpace() &&
abpDaprClientOptions.GrpcChannelOptions != null)
{
builder
.UseGrpcEndpoint(abpDaprClientOptions.GrpcEndpoint)
.UseGrpcChannelOptions(abpDaprClientOptions.GrpcChannelOptions);
}
if (configureClient == null)
{
throw new ArgumentNullException(nameof(configureClient));
}
setup?.Invoke(builder);
services.AddDaprClient();
return builder.Build();
});
var builder = new DefaultDaprClientBuilder(services, name);
builder.ConfigureDaprClient(configureClient);
return builder;
}
services.AddHttpClient(AbpDaprClientModule.DaprHttpClient);
public static IDaprClientBuilder AddDaprClient(
[NotNull] this IServiceCollection services,
string name,
Action<IServiceProvider, DaprClientBuilder> configureClient)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
return services;
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (configureClient == null)
{
throw new ArgumentNullException(nameof(configureClient));
}
services.AddDaprClient();
var builder = new DefaultDaprClientBuilder(services, name);
builder.ConfigureDaprClient(configureClient);
return builder;
}
#endregion
#region Add DaprClient Proxies
public static IServiceCollection AddDaprClientProxies(
[NotNull] this IServiceCollection services,
[NotNull] Assembly assembly,
@ -96,7 +153,7 @@ namespace Microsoft.Extensions.DependencyInjection
Check.NotNull(type, nameof(type));
Check.NotNullOrWhiteSpace(remoteServiceConfigurationName, nameof(remoteServiceConfigurationName));
// AddHttpClientFactory(services, remoteServiceConfigurationName);
services.AddDaprClientFactory(remoteServiceConfigurationName);
services.Configure<AbpDaprClientProxyOptions>(options =>
{
@ -124,6 +181,64 @@ namespace Microsoft.Extensions.DependencyInjection
);
}
services.AddTransient(
typeof(IDaprClientProxy<>).MakeGenericType(type),
serviceProvider =>
{
var service = ProxyGeneratorInstance
.CreateInterfaceProxyWithoutTarget(
type,
(IInterceptor)serviceProvider.GetRequiredService(validationInterceptorAdapterType),
(IInterceptor)serviceProvider.GetRequiredService(interceptorAdapterType)
);
return Activator.CreateInstance(
typeof(DaprClientProxy<>).MakeGenericType(type),
service
);
});
return services;
}
private static IServiceCollection AddDaprClientFactory(
[NotNull] this IServiceCollection services,
[NotNull] string remoteServiceConfigurationName = DaprRemoteServiceConfigurationDictionary.DefaultName)
{
var preOptions = services.ExecutePreConfiguredActions<AbpDaprClientBuilderOptions>();
if (preOptions.ConfiguredProxyClients.Contains(remoteServiceConfigurationName))
{
return services;
}
var clientBuilder = services.AddDaprClient(remoteServiceConfigurationName, (IServiceProvider provider, DaprClientBuilder builder) =>
{
var options = provider.GetRequiredService<IOptions<AbpDaprRemoteServiceOptions>>().Value;
builder.UseHttpEndpoint(
options.RemoteServices
.GetConfigurationOrDefault(remoteServiceConfigurationName).BaseUrl);
foreach (var clientBuildAction in preOptions.ProxyClientBuildActions)
{
clientBuildAction(remoteServiceConfigurationName, provider, builder);
}
});
clientBuilder.ConfigureDaprClient((client) =>
{
foreach (var clientBuildAction in preOptions.ProxyClientActions)
{
clientBuildAction(remoteServiceConfigurationName, client);
}
});
services.PreConfigure<AbpDaprClientBuilderOptions>(options =>
{
options.ConfiguredProxyClients.Add(remoteServiceConfigurationName);
});
return services;
}
@ -136,5 +251,7 @@ namespace Microsoft.Extensions.DependencyInjection
&& !type.IsGenericType
&& typeof(IRemoteService).IsAssignableFrom(type);
}
#endregion
}
}

20
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/README.md

@ -100,14 +100,10 @@ dapr run --app-id myapp --app-port 5000 -H 50000 -G 40001 -- dotnet run
```json
{
"Dapr": {
"Client": {
"HttpEndpoint": "http://127.0.0.1:50000"
}
},
"RemoteServices": {
"System": {
"AppId": "myapp"
"AppId": "myapp",
"BaseUrl": "http://127.0.0.1:50000"
}
}
}
@ -155,24 +151,16 @@ public class InvokeClass
## 配置项说明
* AbpDaprClientOptions.GrpcEndpoint Dapr暴露的Grpc端点, 对应 **DaprClientBuilder.GrpcEndpoint**
* AbpDaprClientOptions.HttpEndpoint Dapr暴露的Http端点, 对应 **DaprClientBuilder.HttpEndpoint**
* AbpDaprClientOptions.GrpcChannelOptions 通过Grpc调用远程服务的配置项, 对应 **DaprClientBuilder.GrpcChannelOptions**
* AbpDaprRemoteServiceOptions.RemoteServices 配置Dapr.AppId
```json
{
"Dapr": {
"Client": {
"HttpEndpoint": "http://127.0.0.1:50000"
}
},
"RemoteServices": {
"System": {
"AppId": "myapp"
"AppId": "myapp",
"BaserUrl": ""http://127.0.0.1:50000""
}
}
}

8
aspnet-core/modules/dapr/README.md

@ -75,14 +75,10 @@ dapr run --app-id myapp --app-port 5000 -H 50000 -G 40001 -- dotnet run
```json
{
"Dapr": {
"Client": {
"HttpEndpoint": "http://127.0.0.1:50000"
}
},
"RemoteActors": {
"System": {
"ActorId": "1"
"ActorId": "1",
"BaseUrl": "http://127.0.0.1:50000"
}
}
}

18
aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN.Abp.Dapr.AspNetCore.TestHost.csproj

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="4.3.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\dapr\LINGYUN.Abp.Dapr.Actors.AspNetCore\LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Dapr.Tests\LINGYUN.Abp.Dapr.Tests.csproj" />
</ItemGroup>
</Project>

39
aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN/Abp/Dapr/AbpDaprAspNetCoreTestHostModule.cs

@ -0,0 +1,39 @@
using LINGYUN.Abp.Dapr.Actors.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Dapr
{
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpDaprActorsAspNetCoreModule)
)]
public class AbpDaprAspNetCoreTestHostModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
Configure<IMvcBuilder>(builder =>
{
builder.AddApplicationPart(typeof(AbpDaprAspNetCoreTestHostModule).Assembly);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseRouting();
app.UseAuditing();
app.UseConfiguredEndpoints();
}
}
}

61
aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN/Abp/Dapr/Actors/TestActor.cs

@ -0,0 +1,61 @@
using Dapr.Actors.Runtime;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.Dapr.Actors
{
public class TestActor : Actor, ITestActor, ISingletonDependency
{
public TestActor(ActorHost host) : base(host)
{
}
public async Task<ListResultDto<NameValue>> GetAsync()
{
var values = await GetValuesByStateAsync();
return new ListResultDto<NameValue>(values);
}
public async Task<NameValue> UpdateAsync()
{
var values = await GetValuesByStateAsync();
var inctement = await StateManager.AddOrUpdateStateAsync(
"test:actors:increment",
1,
(key, value) =>
{
return value + 1;
});
values[0].Value = $"value:updated:{inctement}";
return values[0];
}
public async Task ClearAsync()
{
await StateManager.TryRemoveStateAsync("test:actors:increment");
await StateManager.TryRemoveStateAsync("test:actors");
}
protected virtual async Task<List<NameValue>> GetValuesByStateAsync()
{
return await StateManager
.GetOrAddStateAsync(
"test:actors",
new List<NameValue>
{
new NameValue("name1", "value1"),
new NameValue("name2", "value2"),
new NameValue("name3", "value3"),
new NameValue("name4", "value4"),
new NameValue("name5", "value5")
});
}
}
}

41
aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/LINGYUN/Abp/Dapr/ServiceInvocation/TestAppService.cs

@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Abp.Dapr.ServiceInvocation
{
[RemoteService(Name = "TestDapr")]
[Route("api/dapr/test")]
public class TestAppService : AbpController, ITestAppService
{
private static int _inctement;
private readonly List<NameValue> _cache = new List<NameValue>
{
new NameValue("name1", "value1"),
new NameValue("name2", "value2"),
new NameValue("name3", "value3"),
new NameValue("name4", "value4"),
new NameValue("name5", "value5")
};
[HttpGet]
public Task<ListResultDto<NameValue>> GetAsync()
{
return Task.FromResult(new ListResultDto<NameValue>(_cache));
}
[HttpPut]
public Task<NameValue> UpdateAsync()
{
Interlocked.Increment(ref _inctement);
_cache[0].Value = $"value:updated:{_inctement}";
return Task.FromResult(_cache[0]);
}
}
}

23
aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/Program.cs

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace LINGYUN.Abp.Dapr.AspNetCore.TestHost
{
public class Program
{
public static int Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
return 0;
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac();
}
}

21
aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/Properties/launchSettings.json

@ -0,0 +1,21 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:29703",
"sslPort": 0
}
},
"profiles": {
"LINGYUN.Abp.Dapr.AspNetCore.TestHost": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": false,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

18
aspnet-core/tests/LINGYUN.Abp.Dapr.AspNetCore.TestHost/Startup.cs

@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace LINGYUN.Abp.Dapr.AspNetCore.TestHost
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<AbpDaprAspNetCoreTestHostModule>();
}
public void Configure(IApplicationBuilder app)
{
app.InitializeApplication();
}
}
}

34
aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN.Abp.Dapr.Client.Tests.csproj

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace />
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\dapr\LINGYUN.Abp.Dapr.Client\LINGYUN.Abp.Dapr.Client.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Dapr.Tests\LINGYUN.Abp.Dapr.Tests.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

34
aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN/Abp/Dapr/Client/Tests/AbpDaptClientTestBase.cs

@ -0,0 +1,34 @@
using LINGYUN.Abp.Tests;
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics;
using System.IO;
using System.Threading;
namespace LINGYUN.Abp.Dapr.Client.Tests
{
public class AbpDaptClientTestBase : AbpTestsBase<AbpDaptClientTestModule>
{
// private Process _hostProcess;
//protected override void BeforeAddApplication(IServiceCollection services)
//{
// // TODO: 运行测试前先启动宿主进程 dapr run --app-id testdapr --app-port 5000 -H 10000 -- dotnet run --no-build
// var workingDirectory = Path.Combine(Directory.GetCurrentDirectory(), "../../../../LINGYUN.Abp.Dapr.AspNetCore.TestHost");
// _hostProcess = Process.Start(new ProcessStartInfo
// {
// WorkingDirectory = workingDirectory,
// FileName = "powershell",
// Arguments = "dapr run --app-id testdapr --app-port 5000 -H 10000 -- dotnet run --no-build",
// UseShellExecute = true
// });
// // 等待.NET进程启动完毕
// Thread.Sleep(15000);
//}
//public override void Dispose()
//{
// _hostProcess?.CloseMainWindow();
//}
}
}

33
aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN/Abp/Dapr/Client/Tests/AbpDaptClientTestModule.cs

@ -0,0 +1,33 @@
using LINGYUN.Abp.Tests;
using Volo.Abp.Modularity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace LINGYUN.Abp.Dapr.Client.Tests
{
[DependsOn(
typeof(AbpDaprTestModule),
typeof(AbpTestsBaseModule),
typeof(AbpDaprClientModule))]
public class AbpDaptClientTestModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
context.Services.ReplaceConfiguration(
ConfigurationHelper.BuildConfiguration(
new AbpConfigurationBuilderOptions
{
EnvironmentName = "Development",
BasePath = Directory.GetCurrentDirectory()
}));
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddDaprClientProxies(
typeof(AbpDaprTestModule).Assembly,
"TestDapr");
}
}
}

33
aspnet-core/tests/LINGYUN.Abp.Dapr.Client.Tests/LINGYUN/Abp/Dapr/Client/Tests/TestAppServiceTests.cs

@ -0,0 +1,33 @@
using LINGYUN.Abp.Dapr.ServiceInvocation;
using Shouldly;
using System.Threading.Tasks;
using Xunit;
namespace LINGYUN.Abp.Dapr.Client.Tests
{
public class TestAppServiceTests : AbpDaptClientTestBase
{
private readonly ITestAppService _service;
public TestAppServiceTests()
{
_service = GetRequiredService<ITestAppService>();
}
[Fact]
public async Task Get_Result_Items_Count_Should_5()
{
var result = await _service.GetAsync();
result.Items.Count.ShouldBe(5);
}
[Fact]
public async Task Update_Result_Value_Should_Value_Updated_1()
{
var result = await _service.UpdateAsync();
result.Value.ShouldBe("value:updated:1");
}
}
}

13
aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN.Abp.Dapr.Tests.csproj

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace />
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.Actors" Version="1.1.0" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="4.3.0" />
</ItemGroup>
</Project>

11
aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN/Abp/Dapr/AbpDaprTestModule.cs

@ -0,0 +1,11 @@
using Volo.Abp.Application;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Dapr
{
[DependsOn(
typeof(AbpDddApplicationContractsModule))]
public class AbpDaprTestModule : AbpModule
{
}
}

17
aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN/Abp/Dapr/Actors/ITestActor.cs

@ -0,0 +1,17 @@
using Dapr.Actors;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.Dapr.Actors
{
[RemoteService(Name = "Test")]
public interface ITestActor : IActor
{
Task<ListResultDto<NameValue>> GetAsync();
Task<NameValue> UpdateAsync();
Task ClearAsync();
}
}

14
aspnet-core/tests/LINGYUN.Abp.Dapr.Tests/LINGYUN/Abp/Dapr/ServiceInvocation/ITestAppService.cs

@ -0,0 +1,14 @@
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace LINGYUN.Abp.Dapr.ServiceInvocation
{
public interface ITestAppService : IApplicationService
{
Task<ListResultDto<NameValue>> GetAsync();
Task<NameValue> UpdateAsync();
}
}
Loading…
Cancel
Save