com.ghp.request.enums.RequestLimitStrategy Maven / Gradle / Ivy
package com.ghp.request.enums;
import com.ghp.request.limiter.Limiter;
import com.ghp.request.limiter.impl.*;
/**
* @author ghp
* @title 请求限制策略
* @description
*/
public enum RequestLimitStrategy {
/**
* 固定窗口限流算法
*/
FIXED_WINDOW(new FixedWindowCountLimiter(), "固定窗口限流算法"),
/**
* 滑动窗口限流算法
*/
SLIDE_WINDOW(new SlideWindowCountLimiter(), "滑动窗口限流算法"),
/**
* 漏桶限流算法
*/
LEAKY_BUCKET(new LeakyBucketLimiter(), "漏桶限流算法"),
/**
* 令牌桶限流算法
*/
TOKEN_BUCKET(new TokenBucketLimiter(), "令牌桶限流算法"),
/**
* 令牌桶限流算法(推荐直接使用这种方式,因为这个是谷歌大佬写的,性能和安全都有保障)
* 基于{@link com.google.common.util.concurrent.RateLimiter}实现的限流
*/
RATE_LIMITER(new RateLimiter(), "令牌桶限流算法")
;
/**
* 限流器
*/
private Limiter limiter;
/**
* 描述信息
*/
private String description;
RequestLimitStrategy(Limiter limiter, String description) {
this.limiter = limiter;
this.description = description;
}
public Limiter getLimiter() {
return limiter;
}
public String getDescription() {
return description;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy