mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:13:26 +08:00
【调整】移除第三方AspNetCoreRateLimit限流组件,使用.net8自带的RateLimiter特性。
This commit is contained in:
66
CoreCms.Net.Model/ViewModels/Options/MyRateLimitOptions.cs
Normal file
66
CoreCms.Net.Model/ViewModels/Options/MyRateLimitOptions.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CoreCms.Net.Model.ViewModels.Options
|
||||
{
|
||||
/// <summary>
|
||||
/// 限速设置器配置文件
|
||||
/// 用于UseRateLimiter
|
||||
/// </summary>
|
||||
public class MyRateLimitOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 限速器节点名称
|
||||
/// </summary>
|
||||
public const string MyRateLimit = "MyRateLimit";
|
||||
|
||||
/// <summary>
|
||||
/// 一个窗口中允许的最大允许计数器数。 在将这些选项传递给 的FixedWindowRateLimiter构造函数时,必须设置为值 > 0。
|
||||
/// </summary>
|
||||
public int PermitLimit { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// 指定请求的时间范围。 必须设置为大于 Zero 将这些选项传递给 的构造函数 FixedWindowRateLimiter时的值。
|
||||
/// </summary>
|
||||
public int Window { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// 当 AutoReplenishment 设置为 true 时,内部计时器每 ReplenishmentPeriod 时间补充一次令牌数;当 false 设置为 TryReplenish 时,应用必须对限制器调用 。
|
||||
/// </summary>
|
||||
public int ReplenishmentPeriod { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// 排队的获取请求的最大累计允许计数。 将这些选项传递给 的FixedWindowRateLimiter构造函数时,必须设置为值 >= 0。
|
||||
/// </summary>
|
||||
public int QueueLimit { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int SegmentsPerWindow { get; set; } = 8;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int TokenLimit { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int TokenLimit2 { get; set; } = 20;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int TokensPerPeriod { get; set; } = 4;
|
||||
|
||||
/// <summary>
|
||||
/// 是否自动补货
|
||||
/// </summary>
|
||||
public bool AutoReplenishment { get; set; } = false;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user