001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.jboot.components.limiter.annotation; 017 018import io.jboot.components.limiter.LimitScope; 019import io.jboot.components.limiter.LimitType; 020 021import java.lang.annotation.*; 022 023@Retention(RetentionPolicy.RUNTIME) 024@Target(ElementType.METHOD) 025@Documented 026public @interface EnableLimit { 027 028 /** 029 * 资源名称 030 * 031 * @return 032 */ 033 String resource() default ""; 034 035 /** 036 * 类型 : 037 * 038 * @return 039 */ 040 String type() default LimitType.TOKEN_BUCKET; 041 042 043 /** 044 * 作用域,默认为单节点本地限次 045 */ 046 LimitScope scope() default LimitScope.NODE; 047 048 /** 049 * 频率 050 * 051 * @return 052 */ 053 int rate(); 054 055 056 /** 057 * 降级方法 058 * 059 * @return 060 */ 061 String fallback() default ""; 062 063 064}