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
- Host: GitHub
- URL: https://github.com/os/ratelimiter
- Owner: os
- Created: 2022-04-14T04:58:35.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-21T04:16:40.000Z (about 4 years ago)
- Last Synced: 2025-01-24T10:07:43.449Z (over 1 year ago)
- Language: Go
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```