Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 1.05 KB

File metadata and controls

36 lines (30 loc) · 1.05 KB

Throttle

As a service client, there's little point in sending requests to the service that we can be reasonably sure will fail.

This is a simple library that provides a way to throttle requests to a service based on the number of requests that have been sent in the past. It uses a sliding window algorithm to determine if a request should be sent or not.

The concept comes from chapter 21 of the SRE book. The author has previously released self-throttle, for Node.js. This library is a new implementation of the same concept, rather than a port.

Usage

Include the library in your dependencies:

dependencies {
    implementation 'eu.aylett:throttle:0.1.1'
}