os / ratelimiter

A generic rate limiter implementation in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Running

In Docker

make run

Locally

make run-local

Testing

In Docker

make test

Locally

make test-local

About

A generic rate limiter implementation in Go


Languages

Language:Go 96.8%Language:Dockerfile 1.6%Language:Makefile 1.6%