GithubHelp home page GithubHelp logo

ratelimiter-kevinwang-springboot-starter's Introduction

限流组件

使用aop+google的rateLimiter进行实现

aop进行注解拦截,之后获取注解的信息,并对RateLimiter进行注册和配置,如果能够抢到就执行,否则就限流,类似于抢占锁的概念

使用方法:

@GetMapping("hello")
@DoRateLimiter(permitsPerSecond = 1,returnJson = "{\"code\":\"1111\",\"desc\":\"调用方法超过最大次数,限流返回!!\"}")
public Result sayHello(){
Result result = new Result();
result.setCode("0000");
result.setDesc("调用成功");
return result;
}

permitsPerSecond是最多能够执行的次数,是同时执行,不是执行一次就减少一次。 returnJson是限流以后默认的返回值。json格式。

ratelimiter-kevinwang-springboot-starter's People

Contributors

kevinwangsheng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.