Skip to content

Extract a pluggable, multi-instance-safe RateLimitStore abstraction - #369

Open
NkechiOgbuji wants to merge 1 commit into
Adamantine-guild:mainfrom
NkechiOgbuji:refactor/pluggable-rate-limit-store
Open

Extract a pluggable, multi-instance-safe RateLimitStore abstraction#369
NkechiOgbuji wants to merge 1 commit into
Adamantine-guild:mainfrom
NkechiOgbuji:refactor/pluggable-rate-limit-store

Conversation

@NkechiOgbuji

Copy link
Copy Markdown
Contributor

Close #307

Description

This PR refactors the rate limiting implementation by introducing a pluggable RateLimitStore abstraction, separating the token-bucket algorithm from its storage implementation.

The default behavior remains unchanged through an in-memory store, while making it straightforward to introduce a shared backend (such as Redis) for multi-instance or serverless deployments without modifying the core rate-limiting logic.

Linked Issue

Closes #307

Type of Change

  • Bug fix (UI or API integration)
  • New feature / component
  • UI/UX improvement
  • Documentation update
  • Chore / refactor / dependency update
  • Tests only

Changes Made

  • Introduced a RateLimitStore abstraction to decouple storage from the token-bucket algorithm.
  • Added InMemoryRateLimitStore as the default implementation to preserve existing behavior.
  • Refactored rateLimitRequest to work with an injected store while maintaining backward compatibility.
  • Updated integration API routes to use the refactored rate limiter.
  • Extended the rate-limit test suite to validate the algorithm against an injectable store implementation.
  • Updated deployment documentation with an example of how a shared store (for example, Redis) can be integrated for production deployments.

Validation

  • Focused rate-limit tests pass.
  • Touched files pass TypeScript checks.
  • git diff --check reports no whitespace or merge-marker issues.
  • Existing repository-wide failures are pre-existing baseline issues unrelated to this change.

Notes

This refactor preserves the existing rate-limiting behavior and public API while providing a clean extension point for future shared storage implementations. No new dependencies were introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract a pluggable, multi-instance-safe RateLimitStore abstraction

1 participant