Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(redis_cache): extend DefaultClient class to add support for RedisClusterException #3392

Merged
merged 6 commits into from
Feb 8, 2024

Conversation

gagantrivedi
Copy link
Member

@gagantrivedi gagantrivedi commented Feb 7, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

  • Create a client class that converts RedisClusterException to ConnectionInterrupted(handled/defined by django_redis)
  • set connection_factory as part of init to avoid setting it explicitly
  • Add explicit retry

How did you test this code?

  • Adds unit tests
  • Tested manually against dead redis cluster to make sure the exceptions are only logged and not raised

Copy link

vercel bot commented Feb 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 8, 2024 3:18am
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 8, 2024 3:18am
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 8, 2024 3:18am

Copy link
Contributor

github-actions bot commented Feb 7, 2024

Uffizzi Preview deployment-46032 was deleted.

@gagantrivedi gagantrivedi changed the title fix(redis_cache): Create SafeRedisClusterClient class to avoid application crashing because of redis fix(redis_cache): extend DefaultClient class to add support for RedisClusterException Feb 7, 2024
@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (16e6a28) 95.93% compared to head (8cef2d2) 18.38%.
Report is 10 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3392       +/-   ##
===========================================
- Coverage   95.93%   18.38%   -77.56%     
===========================================
  Files        1077      997       -80     
  Lines       32944    28832     -4112     
===========================================
- Hits        31606     5300    -26306     
- Misses       1338    23532    +22194     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

api/core/redis_cluster.py Show resolved Hide resolved
Comment on lines 55 to 62
def _safe_operation(self, func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except RedisClusterException as e:
raise ConnectionInterrupted(connection=None) from e

return wrapper
Copy link
Member

Choose a reason for hiding this comment

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

Nit: probably should be a staticmethod.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, done

api/core/redis_cluster.py Show resolved Hide resolved
@gagantrivedi gagantrivedi added this pull request to the merge queue Feb 8, 2024
Merged via the queue into main with commit 0949963 Feb 8, 2024
21 checks passed
@gagantrivedi gagantrivedi deleted the fix-catch-redis-errors branch February 8, 2024 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants