An open API service indexing awesome lists of open source software.

https://github.com/os/ratelimiter

A generic rate limiter implementation in Go
https://github.com/os/ratelimiter

Last synced: over 1 year ago
JSON representation

A generic rate limiter implementation in Go

Awesome Lists containing this project

README

          

# Rate Limiter

A generic rate limiter implementation in Go.

## Design

There are a few main concepts:

* **Identifier**: Provides a way to identify the request (e.g. IPIdentifier, TokenIdentifier)
* **Store**: Stores the counter (e.g. MemoryStore, FileStore, RedisStore)
* **Limiter**: Decides if a call is allowed (e.g. FixedWindowLimiter, SlidingWindowLog)

I've used Fixed Window Counter algorithm for this implementation as it's space efficient and easy to implement.

## Requirements

* [Docker](https://docs.docker.com/get-docker/)
* [Go](https://golang.org/dl/)

## Running

### In Docker

```bash
make run
```

### Locally

```bash
make run-local
```

## Testing

### In Docker

```bash
make test
```

### Locally

```bash
make test-local
```