mirror of
https://github.com/smallnest/rpcx.git
synced 2026-04-22 23:27:06 +08:00
add request rate limiter
This commit is contained in:
@@ -30,8 +30,8 @@ func NewReqRateLimitingPlugin(fillInterval time.Duration, capacity int64, block
|
||||
}
|
||||
}
|
||||
|
||||
// DoPreReadRequest can limit request processing.
|
||||
func (plugin *ReqRateLimitingPlugin) DoPreReadRequest(ctx context.Context) error {
|
||||
// PreReadRequest can limit request processing.
|
||||
func (plugin *ReqRateLimitingPlugin) PreReadRequest(ctx context.Context) error {
|
||||
if plugin.block {
|
||||
plugin.bucket.Wait(1)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user