pub struct RateLimitSettings {Show 17 fields
pub strict_per_sec: u32,
pub strict_burst: u32,
pub upload_per_sec: u32,
pub upload_burst: u32,
pub image_per_sec: u32,
pub image_burst: u32,
pub comment_per_sec: u32,
pub comment_burst: u32,
pub comment_upload_per_sec: u32,
pub comment_upload_burst: u32,
pub comment_upload_daily: u32,
pub code_exec_per_sec: u32,
pub code_exec_burst: u32,
pub code_exec_daily: u32,
pub unknown_per_sec: u32,
pub unknown_burst: u32,
pub gc_interval_secs: u32,
}Expand description
限流配置(多级 IP 键控限流器的速率/突发/日限额与 GC 间隔)。
重启生效层:限流器是 LazyLock 静态量,首次请求时构造即固化; 修改 DB 值需重启进程才能生效。
Fields§
§strict_per_sec: u32严格限流(注册/登录)每秒请求数。
strict_burst: u32严格限流突发上限。
upload_per_sec: u32上传限流每秒请求数。
upload_burst: u32上传限流突发上限。
image_per_sec: u32图片访问限流每秒请求数。
image_burst: u32图片访问限流突发上限。
comment_per_sec: u32评论限流每秒请求数。
comment_burst: u32评论限流突发上限。
comment_upload_per_sec: u32评论图片上传限流每秒请求数。
comment_upload_burst: u32评论图片上传限流突发上限。
comment_upload_daily: u32评论图片上传日限额(次/天)。
code_exec_per_sec: u32代码执行限流每秒请求数。
code_exec_burst: u32代码执行限流突发上限。
code_exec_daily: u32代码执行日限额(次/天)。
unknown_per_sec: u32unknown 桶(无法识别 IP)每秒请求数。
unknown_burst: u32unknown 桶突发上限。
gc_interval_secs: u32限流桶 GC 间隔(秒)。
Implementations§
Source§impl RateLimitSettings
impl RateLimitSettings
Sourcepub fn clamp_per_sec(n: u32) -> u32
pub fn clamp_per_sec(n: u32) -> u32
将 per_sec 字段钳制到 [MIN_RATE_LIMIT_PER_SEC, ∞)。
Sourcepub fn clamp_burst(n: u32) -> u32
pub fn clamp_burst(n: u32) -> u32
将 burst 字段钳制到 [MIN_RATE_LIMIT_BURST, ∞)。
Sourcepub fn clamp_daily(n: u32) -> u32
pub fn clamp_daily(n: u32) -> u32
将日限额字段钳制到 [MIN_RATE_LIMIT_DAILY, ∞)。
Sourcepub fn clamp_gc_interval(n: u32) -> u32
pub fn clamp_gc_interval(n: u32) -> u32
将 GC 间隔钳制到 [MIN_RATE_LIMIT_GC_INTERVAL_SECS, ∞)。
Trait Implementations§
Source§impl Clone for RateLimitSettings
impl Clone for RateLimitSettings
Source§fn clone(&self) -> RateLimitSettings
fn clone(&self) -> RateLimitSettings
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RateLimitSettings
impl Debug for RateLimitSettings
Source§impl Default for RateLimitSettings
impl Default for RateLimitSettings
Source§impl<'de> Deserialize<'de> for RateLimitSettings
impl<'de> Deserialize<'de> for RateLimitSettings
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for RateLimitSettings
impl PartialEq for RateLimitSettings
Source§impl Serialize for RateLimitSettings
impl Serialize for RateLimitSettings
impl StructuralPartialEq for RateLimitSettings
Auto Trait Implementations§
impl Freeze for RateLimitSettings
impl RefUnwindSafe for RateLimitSettings
impl Send for RateLimitSettings
impl Sync for RateLimitSettings
impl Unpin for RateLimitSettings
impl UnsafeUnpin for RateLimitSettings
impl UnwindSafe for RateLimitSettings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.
§impl<T> Transportable for Twhere
T: Serialize + DeserializeOwned + 'static,
impl<T> Transportable for Twhere
T: Serialize + DeserializeOwned + 'static,
§fn transport_to_bytes(&self) -> Vec<u8> ⓘ
fn transport_to_bytes(&self) -> Vec<u8> ⓘ
Serialize the type to a byte vector for transport
§fn transport_from_bytes(bytes: &[u8]) -> Result<T, Error<Error>>
fn transport_from_bytes(bytes: &[u8]) -> Result<T, Error<Error>>
Deserialize the type from a byte slice