Browse Source

Introduce IAbpDaprClientFactory

pull/14015/head
Halil İbrahim Kalkan 4 years ago
parent
commit
b01cfa7d98
  1. 7
      framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs
  2. 8
      framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IAbpDaprClientFactory.cs

7
framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs

@ -7,10 +7,11 @@ using Volo.Abp.Json.SystemTextJson;
namespace Volo.Abp.Dapr;
public class AbpDaprClientFactory : ITransientDependency
public class AbpDaprClientFactory : ITransientDependency, IAbpDaprClientFactory
{
protected AbpDaprOptions Options { get; }
protected AbpSystemTextJsonSerializerOptions SystemTextJsonSerializerOptions { get; }
private readonly static ConcurrentDictionary<string, JsonSerializerOptions> JsonSerializerOptionsCache = new();
public AbpDaprClientFactory(
IOptions<AbpDaprOptions> options,
@ -38,11 +39,9 @@ public class AbpDaprClientFactory : ITransientDependency
return builder.Build();
}
private readonly static ConcurrentDictionary<string, JsonSerializerOptions> JsonSerializerOptionsCache = new ConcurrentDictionary<string, JsonSerializerOptions>();
protected virtual Task<JsonSerializerOptions> CreateJsonSerializerOptions()
{
return Task.FromResult(JsonSerializerOptionsCache.GetOrAdd(nameof(AbpDaprClientFactory),
_ => new JsonSerializerOptions(SystemTextJsonSerializerOptions.JsonSerializerOptions)));
}
}
}

8
framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IAbpDaprClientFactory.cs

@ -0,0 +1,8 @@
using Dapr.Client;
namespace Volo.Abp.Dapr;
public interface IAbpDaprClientFactory
{
Task<DaprClient> CreateAsync();
}
Loading…
Cancel
Save