ThrottleInterceptor class
author:郑再红 email:1096877329@qq.com date:2026-08-07 9:44 describe:请求限流/节流拦截器 对请求进行频率限制,在指定时间窗口内相同 key 的请求只放行第一次。
- Inheritance
-
- Object
- AdapterInterceptor
- ThrottleInterceptor
Constructors
- ThrottleInterceptor({Duration duration = const Duration(seconds: 1), String keyBuilder(AdapterRequest request)?})
Properties
- duration → Duration
-
节流时间窗口
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyBuilder → String Function(AdapterRequest request)?
-
自定义 key 生成器,默认使用请求路径
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearAll(
) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError(
AdapterException error, ErrorInterceptorHandler handler) → void -
错误拦截
inherited
-
onRequest(
AdapterRequest request, RequestInterceptorHandler handler) → void -
请求拦截
override
-
onResponse(
AdapterResponse response, ResponseInterceptorHandler handler) → void -
响应拦截
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited