Skip to content

refactoring codebase#25

Merged
amirreza-sf80 merged 41 commits intodjango-commons:mainfrom
amirreza-sf80:refactor
Jun 9, 2025
Merged

refactoring codebase#25
amirreza-sf80 merged 41 commits intodjango-commons:mainfrom
amirreza-sf80:refactor

Conversation

@amirreza-sf80
Copy link
Member

@amirreza-sf80 amirreza-sf80 commented May 7, 2025

this is a sub-pr from #24

  1. refactor the code base to reduce repeated code
  2. add utils for raw usage
  3. sharded client now has get_client, but get_server is removed

NOTES:

refactoring invloves these points:

1.moving all client operations into their own class
2.removing shared methods from other clients, and handling all of them in one method (where possible)
3. removing hardcoded (a) prifix from async code and handling that dynamically
4. turning some async methods into sync so both clients can share them
5. reuse normal sync tests for cluster (as much as possible)
6. document the changes

(cherry picked from commit 53e50d8)
cluster clients don't support the omit_exception functionality, so had to remove the decorator from the methods, which is done be un-decorating them

(cherry picked from commit 1608aec)
(cherry picked from commit b554a14)
(cherry picked from commit a36cd11)
(cherry picked from commit c289d9b)
(cherry picked from commit 95f8542)
(cherry picked from commit 8d22fc8)
(cherry picked from commit 6c6a206)
by moving `get_server` logic to `get_client`, and adjusting operation methods, same methods can be used with shard as well

(cherry picked from commit 21a1ee9)
(cherry picked from commit 4df4565)
(cherry picked from commit 1ea3331)
(cherry picked from commit 71ffd57)
(cherry picked from commit d924df5)
this was done so people can use them with a raw client

(cherry picked from commit d39a5ab)
(cherry picked from commit 772ed71)
this was left out during cherry-picking
@amirreza-sf80
Copy link
Member Author

amirreza-sf80 commented Jun 4, 2025

note for future:
i've tested removing methods from the cache backend and replace them with a __getattr__
but i won't add it to this PR, i need more time to think about it

… them

also changed how `_incr` handles errors
@amirreza-sf80 amirreza-sf80 self-assigned this Jun 9, 2025
@amirreza-sf80 amirreza-sf80 added enhancement New feature or request code quality improve codebase quality labels Jun 9, 2025
@amirreza-sf80 amirreza-sf80 marked this pull request as ready for review June 9, 2025 23:32
@amirreza-sf80 amirreza-sf80 merged commit 9521706 into django-commons:main Jun 9, 2025
21 checks passed
@amirreza-sf80 amirreza-sf80 deleted the refactor branch November 12, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality improve codebase quality enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant