Code Monkey home page Code Monkey logo

limiter-spring-boot-starter's Introduction

limiter-spring-boot-starter

limiter SpringBoot Edition

中文

Support function:

  • Single-machine current limiting
  • Cluster Current Limitation

Tips:

Each time a node is restarted or added, the initial number fills redis, of course, when the capacity is not maximized.    
Specific flow restriction parameters, please cooperate with pressure testing tools to optimize, to achieve the QPS you need.  
If the current limit is successful, the code block with @LimitTraffic annotation will be executed, otherwise it will not be executed to facilitate user-defined schemes, such as service protection degradation, etc.  
In order to improve performance without strong consistency, the maximum current limiting error is -1 cluster number.  

Quick Start

<!--Adding dependencies to pom. XML-->
        <dependency>
            <artifactId>limiter-spring-boot-starter</artifactId>
            <groupId>com.github.thierrysquirrel</groupId>
            <version>1.0.3-RELEASE</version>
        </dependency>

configuration file

## application.properties
spring.redis.host= #Your redis address
spring.redis.port= #The port number of your redis

Start limiter

@SpringBootApplication
@EnableLimiter
public class DemoApplication{
    public static void main(String[] args){
        SpringApplication.run(DemoApplication.class, args);
    }  
}

Current Limitation

@TokenLimitedTraffic
public class Hello {
	@LimitTraffic(initialQuantity = 2333, maximumCapacity = 3222, addedQuantity = 2333)
	public String hello() {
		return "world";
	}
}

Custom operation

@RestController
public class World {
	@Resource
	private Hello hello;

	@GetMapping("/world")
	public String world() {
		String hello = this.hello.hello();
		boolean empty = StringUtils.isEmpty(hello);
		if (empty) {
			return "service degradation";
		}
		return hello;
	}
}

limiter-spring-boot-starter's People

Contributors

thierrysquirrel avatar

Forkers

15662664518

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.