Skip to content

os/ratelimiter

Repository files navigation

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published