diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index cc0018760..6958e012f 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -434,13 +434,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "caching", "caching", "{63FC EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.CachingManagement.Domain", "modules\caching\LINGYUN.Abp.CachingManagement.Domain\LINGYUN.Abp.CachingManagement.Domain.csproj", "{7D6AE2BB-7DBF-4FC8-A1F5-C004D139B278}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.CachingManagement.StackExchangeRedis", "modules\caching\LINGYUN.Abp.CachingManagement.StackExchangeRedis\LINGYUN.Abp.CachingManagement.StackExchangeRedis.csproj", "{920867B4-4740-4074-9B49-14002B272A63}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.CachingManagement.StackExchangeRedis", "modules\caching\LINGYUN.Abp.CachingManagement.StackExchangeRedis\LINGYUN.Abp.CachingManagement.StackExchangeRedis.csproj", "{920867B4-4740-4074-9B49-14002B272A63}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.CachingManagement.Application.Contracts", "modules\caching\LINGYUN.Abp.CachingManagement.Application.Contracts\LINGYUN.Abp.CachingManagement.Application.Contracts.csproj", "{3D422738-B111-4DEE-82E1-C3A90F1133B1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.CachingManagement.Application.Contracts", "modules\caching\LINGYUN.Abp.CachingManagement.Application.Contracts\LINGYUN.Abp.CachingManagement.Application.Contracts.csproj", "{3D422738-B111-4DEE-82E1-C3A90F1133B1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.CachingManagement.Application", "modules\caching\LINGYUN.Abp.CachingManagement.Application\LINGYUN.Abp.CachingManagement.Application.csproj", "{08CC528E-98D7-41D9-957D-9F9064645788}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.CachingManagement.Application", "modules\caching\LINGYUN.Abp.CachingManagement.Application\LINGYUN.Abp.CachingManagement.Application.csproj", "{08CC528E-98D7-41D9-957D-9F9064645788}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.CachingManagement.HttpApi", "modules\caching\LINGYUN.Abp.CachingManagement.HttpApi\LINGYUN.Abp.CachingManagement.HttpApi.csproj", "{B507D18B-770E-4581-854B-15579AC7074F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.CachingManagement.HttpApi", "modules\caching\LINGYUN.Abp.CachingManagement.HttpApi\LINGYUN.Abp.CachingManagement.HttpApi.csproj", "{B507D18B-770E-4581-854B-15579AC7074F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.DistributedLocking.Dapr", "modules\dapr\LINGYUN.Abp.DistributedLocking.Dapr\LINGYUN.Abp.DistributedLocking.Dapr.csproj", "{178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1148,6 +1150,10 @@ Global {B507D18B-770E-4581-854B-15579AC7074F}.Debug|Any CPU.Build.0 = Debug|Any CPU {B507D18B-770E-4581-854B-15579AC7074F}.Release|Any CPU.ActiveCfg = Release|Any CPU {B507D18B-770E-4581-854B-15579AC7074F}.Release|Any CPU.Build.0 = Release|Any CPU + {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1364,6 +1370,7 @@ Global {3D422738-B111-4DEE-82E1-C3A90F1133B1} = {63FCC71F-1CEF-44D3-B95B-23EE58DE8C95} {08CC528E-98D7-41D9-957D-9F9064645788} = {63FCC71F-1CEF-44D3-B95B-23EE58DE8C95} {B507D18B-770E-4581-854B-15579AC7074F} = {63FCC71F-1CEF-44D3-B95B-23EE58DE8C95} + {178AF3DE-1C24-41A9-8CA0-64A7D85DDFFE} = {DC33925B-264D-421B-96CC-46F853CBCC70} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/LINGYUN.MicroService.Common.sln b/aspnet-core/LINGYUN.MicroService.Common.sln index 6bad06cfe..8fc9805b8 100644 --- a/aspnet-core/LINGYUN.MicroService.Common.sln +++ b/aspnet-core/LINGYUN.MicroService.Common.sln @@ -234,7 +234,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "authorization", "authorizat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Authorization.OrganizationUnits", "modules\authorization\LINGYUN.Abp.Authorization.OrganizationUnits\LINGYUN.Abp.Authorization.OrganizationUnits.csproj", "{D9339CBB-45B9-4701-B2AC-2A75FF20D77B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Identity.OrganizaztionUnits", "modules\authorization\LINGYUN.Abp.Identity.OrganizaztionUnits\LINGYUN.Abp.Identity.OrganizaztionUnits.csproj", "{474AA48F-65F9-436B-A0B1-1E95BD16CA8D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.OrganizaztionUnits", "modules\authorization\LINGYUN.Abp.Identity.OrganizaztionUnits\LINGYUN.Abp.Identity.OrganizaztionUnits.csproj", "{474AA48F-65F9-436B-A0B1-1E95BD16CA8D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.DistributedLocking.Dapr", "modules\dapr\LINGYUN.Abp.DistributedLocking.Dapr\LINGYUN.Abp.DistributedLocking.Dapr.csproj", "{C71F6273-BCDE-4A63-A0CF-EAFD1D924DA0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -602,6 +604,10 @@ Global {474AA48F-65F9-436B-A0B1-1E95BD16CA8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {474AA48F-65F9-436B-A0B1-1E95BD16CA8D}.Release|Any CPU.ActiveCfg = Release|Any CPU {474AA48F-65F9-436B-A0B1-1E95BD16CA8D}.Release|Any CPU.Build.0 = Release|Any CPU + {C71F6273-BCDE-4A63-A0CF-EAFD1D924DA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C71F6273-BCDE-4A63-A0CF-EAFD1D924DA0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C71F6273-BCDE-4A63-A0CF-EAFD1D924DA0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C71F6273-BCDE-4A63-A0CF-EAFD1D924DA0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -719,6 +725,7 @@ Global {3971AD93-BF97-4E05-972D-CB5EB9F6CB88} = {02EA4E78-5891-43BC-944F-3E52FEE032E4} {D9339CBB-45B9-4701-B2AC-2A75FF20D77B} = {3971AD93-BF97-4E05-972D-CB5EB9F6CB88} {474AA48F-65F9-436B-A0B1-1E95BD16CA8D} = {3971AD93-BF97-4E05-972D-CB5EB9F6CB88} + {C71F6273-BCDE-4A63-A0CF-EAFD1D924DA0} = {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.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs index c54581015..c5d34a9c4 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 @@ -10,7 +10,6 @@ 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; namespace Microsoft.Extensions.DependencyInjection @@ -126,10 +125,6 @@ namespace Microsoft.Extensions.DependencyInjection var clientBuilder = services.AddDaprClient(remoteServiceConfigurationName, (IServiceProvider provider, DaprClientBuilder builder) => { - // TODO: 是否有必要? 使用框架的序列化配置 - var jsonOptions = provider.GetRequiredService>().Value; - builder.UseJsonSerializationOptions(jsonOptions.JsonSerializerOptions); - var options = provider.GetRequiredService>().Value; builder.UseHttpEndpoint( options.RemoteServices diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/DefaultDaprClientFactory.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/DefaultDaprClientFactory.cs index ba6efeb69..c414e029c 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/DefaultDaprClientFactory.cs +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/DefaultDaprClientFactory.cs @@ -1,23 +1,30 @@ using Microsoft.Extensions.Options; using System; using System.Collections.Concurrent; +using System.Text.Json; using System.Threading; +using Volo.Abp.Json.SystemTextJson; namespace Dapr.Client { public class DefaultDaprClientFactory : IDaprClientFactory { - private readonly IOptionsMonitor _optionsMonitor; + private readonly AbpSystemTextJsonSerializerOptions _systemTextJsonSerializerOptions; + private readonly IOptionsMonitor _daprClientFactoryOptions; private readonly Func> _daprClientFactory; internal readonly ConcurrentDictionary> _daprClients; + internal readonly ConcurrentDictionary _jsonSerializerOptions; public DefaultDaprClientFactory( - IOptionsMonitor optionsMonitor) + IOptions systemTextJsonSerializerOptions, + IOptionsMonitor daprClientFactoryOptions) { - _optionsMonitor = optionsMonitor ?? throw new ArgumentNullException(nameof(optionsMonitor)); + _daprClientFactoryOptions = daprClientFactoryOptions ?? throw new ArgumentNullException(nameof(daprClientFactoryOptions)); + _systemTextJsonSerializerOptions= systemTextJsonSerializerOptions?.Value ?? throw new ArgumentNullException(nameof(systemTextJsonSerializerOptions)); _daprClients = new ConcurrentDictionary>(); + _jsonSerializerOptions = new ConcurrentDictionary(); _daprClientFactory = (name) => { @@ -37,8 +44,8 @@ namespace Dapr.Client var client = _daprClients.GetOrAdd(name, _daprClientFactory).Value; - var options = _optionsMonitor.Get(name); - for (int i = 0; i < options.DaprClientActions.Count; i++) + var options = _daprClientFactoryOptions.Get(name); + for (var i = 0; i < options.DaprClientActions.Count; i++) { options.DaprClientActions[i](client); } @@ -50,7 +57,7 @@ namespace Dapr.Client { var builder = new DaprClientBuilder(); - var options = _optionsMonitor.Get(name); + var options = _daprClientFactoryOptions.Get(name); if (!string.IsNullOrWhiteSpace(options.HttpEndpoint)) { @@ -68,15 +75,25 @@ namespace Dapr.Client { builder.UseJsonSerializationOptions(options.JsonSerializerOptions); } + else + { + builder.UseJsonSerializationOptions(CreateJsonSerializerOptions(name)); + } builder.UseDaprApiToken(options.DaprApiToken); - for (int i = 0; i < options.DaprClientBuilderActions.Count; i++) + for (var i = 0; i < options.DaprClientBuilderActions.Count; i++) { options.DaprClientBuilderActions[i](builder); } return builder.Build(); } + + private JsonSerializerOptions CreateJsonSerializerOptions(string name) + { + return _jsonSerializerOptions.GetOrAdd(name, + _ => new JsonSerializerOptions(_systemTextJsonSerializerOptions.JsonSerializerOptions)); + } } } diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/IDaprClientFactoryExtensions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/IDaprClientFactoryExtensions.cs new file mode 100644 index 000000000..104ecbcb9 --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/IDaprClientFactoryExtensions.cs @@ -0,0 +1,10 @@ +namespace Dapr.Client; + +public static class IDaprClientFactoryExtensions +{ + public static DaprClient CreateClient( + this IDaprClientFactory clientFactory) + { + return clientFactory.CreateClient("Default"); + } +} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj index c33dd8b33..1641159ee 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj @@ -9,7 +9,7 @@ - + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xml b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xsd b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.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/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj new file mode 100644 index 000000000..be2e66567 --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj @@ -0,0 +1,21 @@ + + + + + + + net6.0 + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs new file mode 100644 index 000000000..3a12a6f32 --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs @@ -0,0 +1,15 @@ +using LINGYUN.Abp.Dapr; +using Volo.Abp.DistributedLocking; +using Volo.Abp.Modularity; +using Volo.Abp.Threading; + +namespace LINGYUN.Abp.DistributedLocking.Dapr; + +[DependsOn( + typeof(AbpDaprModule), + typeof(AbpThreadingModule), + typeof(AbpDistributedLockingAbstractionsModule))] +public class AbpDistributedLockingDaprModule : AbpModule +{ + +} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprOptions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprOptions.cs new file mode 100644 index 000000000..054b6b4b8 --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprOptions.cs @@ -0,0 +1,17 @@ +using System; + +namespace LINGYUN.Abp.DistributedLocking.Dapr; + +public class AbpDistributedLockingDaprOptions +{ + public string StoreName { get; set; } + public string ResourceId { get; set; } + public TimeSpan DefaultTimeout { get; set; } + + public AbpDistributedLockingDaprOptions() + { + StoreName = "lockstore"; + ResourceId = "dapr-lock-id"; + DefaultTimeout = TimeSpan.FromSeconds(30); + } +} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs new file mode 100644 index 000000000..848fbd819 --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs @@ -0,0 +1,51 @@ +using Dapr.Client; +using Microsoft.Extensions.Options; +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.DistributedLocking; +using Volo.Abp.Threading; + +namespace LINGYUN.Abp.DistributedLocking.Dapr; + +[Dependency(ReplaceServices = true)] +public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency +{ + protected IDaprClientFactory DaprClientFactory { get; } + protected AbpDistributedLockingDaprOptions Options { get; } + protected ICancellationTokenProvider CancellationTokenProvider { get; } + + public DaprAbpDistributedLock( + IDaprClientFactory daprClientFactory, + ICancellationTokenProvider cancellationTokenProvider, + IOptions options) + { + Options = options.Value; + DaprClientFactory = daprClientFactory; + CancellationTokenProvider = cancellationTokenProvider; + } + + public async virtual Task TryAcquireAsync(string name, TimeSpan timeout = default, CancellationToken cancellationToken = default) + { + if (timeout == default) + { + timeout = Options.DefaultTimeout; + } + var client = DaprClientFactory.CreateClient(); + + var res = await client.Lock(Options.StoreName, name, Options.ResourceId, (int)timeout.TotalSeconds, cancellationToken); + + if (res == null || !res.Success) + { + return null; + } + + return new DaprAbpDistributedLockHandle(Options.StoreName, name, Options.ResourceId, client); + } + + protected virtual CancellationToken GetCancellationToken(CancellationToken cancellationToken = default) + { + return CancellationTokenProvider.FallbackToProvider(cancellationToken); + } +} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs new file mode 100644 index 000000000..fc57e72ab --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs @@ -0,0 +1,28 @@ +using Dapr.Client; +using System.Threading.Tasks; +using Volo.Abp.DistributedLocking; + +namespace LINGYUN.Abp.DistributedLocking.Dapr; + +public class DaprAbpDistributedLockHandle : IAbpDistributedLockHandle +{ + protected string StoreName { get; } + protected string ResourceId { get; } + protected string LockOwner { get; } + protected DaprClient DaprClient { get; } + public DaprAbpDistributedLockHandle( + string storeName, + string resourceId, + string lockOwner, + DaprClient daprClient) + { + StoreName = storeName; + ResourceId = resourceId; + LockOwner = lockOwner; + DaprClient = daprClient; + } + public async ValueTask DisposeAsync() + { + await DaprClient.Unlock(StoreName, ResourceId, LockOwner); + } +} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/README.md b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/README.md new file mode 100644 index 000000000..54c4680d1 --- /dev/null +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/README.md @@ -0,0 +1,34 @@ +# LINGYUN.Abp.DistributedLocking.Dapr + +Abp分布式锁的Dapr实现 + +See: https://docs.dapr.io/developing-applications/building-blocks/distributed-lock/distributed-lock-api-overview/ + +## 配置使用 + +模块按需引用 + +```csharp +[DependsOn(typeof(AbpDistributedLockingDaprModule))] +public class YouProjectModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.StoreName = "store-name"; + options.ResourceId = "resource-id"; + options.DefaultTimeout = TimeSpan.FromSeconds(30); + }); + } +} +``` + +## 配置说明 + +* AbpDistributedLockingDaprOptions.StoreName 在dapr component文件中定义的metadata name,默认: lockstore; +* AbpDistributedLockingDaprOptions.ResourceId 自定义一个资源名称,用于向dapr提供锁定的标识,默认: dapr-lock-id; +* AbpDistributedLockingDaprOptions.DefaultTimeout 默认锁定超时时间,默认: 30s. + + +## 其他