All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.dengchen2020.ratelimiter.annotation.RateLimit Maven / Gradle / Ivy

There is a newer version: 0.0.28
Show newest version
package io.github.dengchen2020.ratelimiter.annotation;

import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;

/**
 * 限流注解
 *
 * @author dengchen
 * @since 2024/4/18
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface RateLimit {

    /**
     * 限制次数
     */
    int value() default 60;

    /**
     * 时间单位,仅支持秒级、分钟级
     */
    TimeUnit timeUnit() default TimeUnit.MINUTES;

    /**
     * 异常提示
     */
    String errorMsg() default "请求过于频繁,请稍后再试";

    /**
     * 限流策略
     */
    RateLimitStrategy strategy() default RateLimitStrategy.userAndUri;

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy