Browse Source

update README.md

pull/296/head
cKey 4 years ago
parent
commit
743b5b29c8
  1. 7
      aspnet-core/LINGYUN.MicroService.Common.sln
  2. 59
      aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation.Redis/LINGYUN/Abp/Features/LimitValidation/Redis/RedisRequiresLimitFeatureChecker.cs
  3. 44
      aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/README.en.md
  4. 44
      aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/README.md
  5. 2
      aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/README.md

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

@ -156,6 +156,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.Http
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.IM.SignalR", "modules\common\LINGYUN.Abp.IM.SignalR\LINGYUN.Abp.IM.SignalR.csproj", "{DEB98AD7-9630-4F32-89E6-C1A118D1D18C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.WeChat", "modules\wechat\LINGYUN.Abp.Identity.WeChat\LINGYUN.Abp.Identity.WeChat.csproj", "{00F1D30E-A6F6-464F-A80B-D423CFAA79A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -406,6 +408,10 @@ Global
{DEB98AD7-9630-4F32-89E6-C1A118D1D18C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEB98AD7-9630-4F32-89E6-C1A118D1D18C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEB98AD7-9630-4F32-89E6-C1A118D1D18C}.Release|Any CPU.Build.0 = Release|Any CPU
{00F1D30E-A6F6-464F-A80B-D423CFAA79A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00F1D30E-A6F6-464F-A80B-D423CFAA79A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00F1D30E-A6F6-464F-A80B-D423CFAA79A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00F1D30E-A6F6-464F-A80B-D423CFAA79A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -484,6 +490,7 @@ Global
{CF30221B-CA7A-42CD-B91A-B7224AB2F38B} = {B86C21A4-73B7-471E-B73A-B4B905EC9435}
{191BB108-546E-4E70-978E-D6A8149C319C} = {086BE5BE-8594-4DA7-8819-935FEF76DABD}
{DEB98AD7-9630-4F32-89E6-C1A118D1D18C} = {B91F26C5-B148-4094-B5F1-71E5F945DBED}
{00F1D30E-A6F6-464F-A80B-D423CFAA79A3} = {22C61434-D29A-4376-AD56-F5089F3E617A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06C707C6-02C0-411A-AD3B-2D0E13787CB8}

59
aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation.Redis/LINGYUN/Abp/Features/LimitValidation/Redis/RedisRequiresLimitFeatureChecker.cs

@ -85,7 +85,7 @@ namespace LINGYUN.Abp.Features.LimitValidation.Redis
var result = await _redis.ScriptEvaluateAsync(luaSha1, keys, values);
if (result.Type == ResultType.Error)
{
throw new AbpException($"脚本执行错误:{result}");
throw new AbpException($"Script evaluate error: {result}");
}
return (int)result;
}
@ -95,20 +95,6 @@ namespace LINGYUN.Abp.Features.LimitValidation.Redis
return _featureNamingNormalizer.NormalizeFeatureName(_instance, context);
}
private void RegistenConnectionEvent(ConnectionMultiplexer connection)
{
if (connection != null)
{
connection.ConnectionFailed += OnConnectionFailed;
connection.ConnectionRestored += OnConnectionRestored;
connection.ErrorMessage += OnErrorMessage;
connection.ConfigurationChanged += OnConfigurationChanged;
connection.HashSlotMoved += OnHashSlotMoved;
connection.InternalError += OnInternalError;
connection.ConfigurationChangedBroadcast += OnConfigurationChangedBroadcast;
}
}
private async Task ConnectAsync(CancellationToken token = default(CancellationToken))
{
token.ThrowIfCancellationRequested();
@ -134,7 +120,7 @@ namespace LINGYUN.Abp.Features.LimitValidation.Redis
_redisConfig.AllowAdmin = true;
_redisConfig.SetDefaultPorts();
_connection = await ConnectionMultiplexer.ConnectAsync(_redisConfig);
RegistenConnectionEvent(_connection);
// fix: 无需关注redis连接事件
_redis = _connection.GetDatabase();
_server = _connection.GetServer(_redisConfig.EndPoints[0]);
}
@ -144,46 +130,5 @@ namespace LINGYUN.Abp.Features.LimitValidation.Redis
_connectionLock.Release();
}
}
private void OnConfigurationChangedBroadcast(object sender, EndPointEventArgs e)
{
Logger.LogInformation("Redis server master/slave changes");
}
private void OnInternalError(object sender, InternalErrorEventArgs e)
{
Logger.LogError("Redis internal error, origin:{0}, connectionType:{1}",
e.Origin, e.ConnectionType);
Logger.LogError(e.Exception, "Redis internal error");
}
private void OnHashSlotMoved(object sender, HashSlotMovedEventArgs e)
{
Logger.LogInformation("Redis configuration changed");
}
private void OnConfigurationChanged(object sender, EndPointEventArgs e)
{
Logger.LogInformation("Redis configuration changed");
}
private void OnErrorMessage(object sender, RedisErrorEventArgs e)
{
Logger.LogWarning("Redis error, message:{0}", e.Message);
}
private void OnConnectionRestored(object sender, ConnectionFailedEventArgs e)
{
Logger.LogWarning("Redis connection restored, failureType:{0}, connectionType:{1}",
e.FailureType, e.ConnectionType);
}
private void OnConnectionFailed(object sender, ConnectionFailedEventArgs e)
{
Logger.LogError("Redis connection failed, failureType:{0}, connectionType:{1}",
e.FailureType, e.ConnectionType);
Logger.LogError(e.Exception, "Redis lock connection failed");
}
}
}

44
aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/README.en.md

@ -24,6 +24,50 @@ public class YouProjectModule : AbpModule
{
// other
}
public static class FakeFeatureNames
{
public const string GroupName = "FakeFeature.Tests";
// Type Limit feature name
public const string ClassLimitFeature = GroupName + ".LimitFeature";
// Method limits the number of calls to the feature name
public const string MethodLimitFeature = GroupName + ".MethodLimitFeature";
// Limit the call interval feature name
public const string IntervalFeature = GroupName + ".IntervalFeature";
}
// Traffic limiting depends on user-defined features
public class FakeFeatureDefinitionProvider : FeatureDefinitionProvider
{
public override void Define(IFeatureDefinitionContext context)
{
var featureGroup = context.AddGroup(FakeFeatureNames.GroupName);
featureGroup.AddFeature(
name: FakeFeatureNames.ClassLimitFeature,
defaultValue: 1000.ToString(), // A maximum of 1000 calls can be made within a period
valueType: new ToggleStringValueType(new NumericValueValidator(1, 1000)));
featureGroup.AddFeature(
name: FakeFeatureNames.MethodLimitFeature,
defaultValue: 100.ToString(), // A maximum of 100 calls can be made within a period
valueType: new ToggleStringValueType(new NumericValueValidator(1, 1000)));
featureGroup.AddFeature(
name: FakeFeatureNames.IntervalFeature,
defaultValue: 1.ToString(), // Limit cycle
valueType: new ToggleStringValueType(new NumericValueValidator(1, 1000)));
}
}
// By default, the type is allowed to be called only 1000 times a day
[RequiresLimitFeature(FakeFeatureNames.ClassLimitFeature, FakeFeatureNames.IntervalFeature, LimitPolicy.Days)]
public class FakeLimitClass
{
// By default, the method is only allowed to be called 100 times a minute
[RequiresLimitFeature(FakeFeatureNames.MethodLimitFeature, FakeFeatureNames.IntervalFeature, LimitPolicy.Minute)]
public void LimitMethod()
{
// other...
}
}
```
If you want to limit the policy duration by self-processing, override the default policy for the corresponding policy and always return a clock scale in seconds

44
aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/README.md

@ -24,6 +24,50 @@ public class YouProjectModule : AbpModule
{
// other
}
public static class FakeFeatureNames
{
public const string GroupName = "FakeFeature.Tests";
// 类型限制调用次数功能名称
public const string ClassLimitFeature = GroupName + ".LimitFeature";
// 方法限制调用次数功能名称
public const string MethodLimitFeature = GroupName + ".MethodLimitFeature";
// 限制调用间隔功能名称
public const string IntervalFeature = GroupName + ".IntervalFeature";
}
// 流量限制依赖自定义功能
public class FakeFeatureDefinitionProvider : FeatureDefinitionProvider
{
public override void Define(IFeatureDefinitionContext context)
{
var featureGroup = context.AddGroup(FakeFeatureNames.GroupName);
featureGroup.AddFeature(
name: FakeFeatureNames.ClassLimitFeature,
defaultValue: 1000.ToString(), // 周期内最大允许调用1000次
valueType: new ToggleStringValueType(new NumericValueValidator(1, 1000)));
featureGroup.AddFeature(
name: FakeFeatureNames.MethodLimitFeature,
defaultValue: 100.ToString(), // 周期内最大允许调用100次
valueType: new ToggleStringValueType(new NumericValueValidator(1, 1000)));
featureGroup.AddFeature(
name: FakeFeatureNames.IntervalFeature,
defaultValue: 1.ToString(), // 限制周期
valueType: new ToggleStringValueType(new NumericValueValidator(1, 1000)));
}
}
// 按照预设的参数,类型在一天钟内仅允许调用1000次
[RequiresLimitFeature(FakeFeatureNames.ClassLimitFeature, FakeFeatureNames.IntervalFeature, LimitPolicy.Days)]
public class FakeLimitClass
{
// 按照预设的参数,方法在一分钟内仅允许调用100次
[RequiresLimitFeature(FakeFeatureNames.MethodLimitFeature, FakeFeatureNames.IntervalFeature, LimitPolicy.Minute)]
public void LimitMethod()
{
// other...
}
}
```
如果需要自行处理功能限制策略时长,请覆盖对应策略的默认策略,返回的时钟刻度单位始终是秒

2
aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/README.md

@ -51,7 +51,7 @@ Xml文件格式如下
```xml
<?xml version="1.0" encoding="utf-8"?>
<localization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="lingyun.abp">
<localization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<culture name="en" />
<texts>
<text key="Hello China" value="Hello China!" />

Loading…
Cancel
Save