Fix #643 -- Add client_fractory to Redis check#651
Conversation
Redis clients may leak connections between concurrent requests. To prevent this we need to instanciate a client per request.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #651 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 13 13
Lines 722 738 +16
=========================================
+ Hits 722 738 +16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot update the test suite to match the new implementation and add deprecation and regression tests. |
|
@codingjoe I've opened a new pull request, #652, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent Redis client/connection leakage across concurrent requests by introducing a client_factory pattern for the Redis health check, updating tests and installation docs accordingly.
Changes:
- Add
client_factoryto the Redis health check and deprecate theclientparameter. - Update Redis contrib tests to use
client_factoryand assert client closing behavior. - Update installation documentation to configure Redis checks using
client_factory.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
health_check/contrib/redis.py |
Adds client_factory, deprecates client, and adjusts initialization/closing behavior. |
tests/contrib/test_redis.py |
Migrates tests to client_factory, adds deprecation coverage, and new lifecycle assertions. |
docs/install.md |
Updates example configuration to pass client_factory instead of a client instance. |
|
@copilot address the review comments. |
|
@codingjoe I've opened a new pull request, #653, to work on those changes. Once the pull request is ready, I'll request review from you. |
- Create client per request in run() method, not in __post_init__ - Add validation requiring exactly one of client or client_factory - Only close factory-created clients, not user-provided ones - Move deprecation warning to __post_init__ for early feedback - Update tests to verify new behavior and lifecycle management Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
Redis clients may leak connections between concurrent requests.
To prevent this we need to instanciate a client per request.