Skip to content

feat: accept redis client in rate limit RedisBackend#393

Open
ComeBertrand wants to merge 1 commit intomasterfrom
limit-client
Open

feat: accept redis client in rate limit RedisBackend#393
ComeBertrand wants to merge 1 commit intomasterfrom
limit-client

Conversation

@ComeBertrand
Copy link
Contributor

Allow passing a pre-built redis.Redis client as an alternative to a URL. When a client is provided, its connection_pool is reused by the limits RedisStorage, consistent with other remoulade Redis backends.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for supplying a pre-built redis.Redis client to the rate limit RedisBackend, so the backend can reuse an existing connection_pool instead of always constructing storage from a URL—aligning rate-limit Redis behavior with other Remoulade Redis backends.

Changes:

  • Extend remoulade.rate_limits.backends.RedisBackend to accept client and make url optional, raising when neither is provided.
  • Add/adjust test fixtures to exercise rate limiting against stub, Redis-by-URL, and Redis-by-client backends.
  • Add a unit test asserting RedisBackend() requires either url or client.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
remoulade/rate_limits/backends/redis.py Accept optional client, optional url, and build limits Redis storage from a provided connection pool.
tests/conftest.py Introduce fixtures for Redis rate-limit backends (URL/client) and parametrize rate_limit_backend.
tests/middleware/test_rate_limit.py Add a test for the “url or client required” constructor validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Allow passing a pre-built redis.Redis client as an alternative to a URL.
When a client is provided, its connection_pool is reused by the limits
RedisStorage, consistent with other remoulade Redis backends.
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.

2 participants