Browse Source

add DistributedLocking Dapr module

pull/645/head
cKey 3 years ago
parent
commit
c1c075bebf
  1. 15
      aspnet-core/LINGYUN.MicroService.All.sln
  2. 9
      aspnet-core/LINGYUN.MicroService.Common.sln
  3. 5
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicDaprClientProxyExtensions.cs
  4. 31
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/DefaultDaprClientFactory.cs
  5. 10
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/Dapr/Client/IDaprClientFactoryExtensions.cs
  6. 2
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj
  7. 3
      aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xml
  8. 30
      aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xsd
  9. 21
      aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj
  10. 15
      aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs
  11. 17
      aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprOptions.cs
  12. 51
      aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs
  13. 28
      aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs
  14. 34
      aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/README.md

15
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}

9
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}

5
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<IOptions<AbpSystemTextJsonSerializerOptions>>().Value;
builder.UseJsonSerializationOptions(jsonOptions.JsonSerializerOptions);
var options = provider.GetRequiredService<IOptions<AbpRemoteServiceOptions>>().Value;
builder.UseHttpEndpoint(
options.RemoteServices

31
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<DaprClientFactoryOptions> _optionsMonitor;
private readonly AbpSystemTextJsonSerializerOptions _systemTextJsonSerializerOptions;
private readonly IOptionsMonitor<DaprClientFactoryOptions> _daprClientFactoryOptions;
private readonly Func<string, Lazy<DaprClient>> _daprClientFactory;
internal readonly ConcurrentDictionary<string, Lazy<DaprClient>> _daprClients;
internal readonly ConcurrentDictionary<string, JsonSerializerOptions> _jsonSerializerOptions;
public DefaultDaprClientFactory(
IOptionsMonitor<DaprClientFactoryOptions> optionsMonitor)
IOptions<AbpSystemTextJsonSerializerOptions> systemTextJsonSerializerOptions,
IOptionsMonitor<DaprClientFactoryOptions> 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<string, Lazy<DaprClient>>();
_jsonSerializerOptions = new ConcurrentDictionary<string, JsonSerializerOptions>();
_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));
}
}
}

10
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");
}
}

2
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj

@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Core" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Dapr.Client" Version="$(DaprPackageVersion)" />
</ItemGroup>

3
aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

30
aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/FodyWeavers.xsd

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

21
aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Threading" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.DistributedLocking.Abstractions" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Dapr\LINGYUN.Abp.Dapr.csproj" />
</ItemGroup>
</Project>

15
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
{
}

17
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);
}
}

51
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<AbpDistributedLockingDaprOptions> options)
{
Options = options.Value;
DaprClientFactory = daprClientFactory;
CancellationTokenProvider = cancellationTokenProvider;
}
public async virtual Task<IAbpDistributedLockHandle> 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);
}
}

28
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);
}
}

34
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<AbpDistributedLockingDaprOptions>(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.
## 其他
Loading…
Cancel
Save