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

Migrating commands to a mixin #1534

Merged
merged 5 commits into from
Aug 18, 2021
Merged

Migrating commands to a mixin #1534

merged 5 commits into from
Aug 18, 2021

Conversation

chayim
Copy link
Contributor

@chayim chayim commented Aug 4, 2021

This patterns allows for the reuse of these commands across connection types, including modules that are based on this client.

This doesn't break any APIs as evident by the lack of change in unit tests.

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Commands, and their associated helpers were moved from redis/client.py and added to redis/commands.py.

This patterns allows for the reuse of these commands across connection types, including modules that are based on this client
@barshaul
Copy link
Contributor

barshaul commented Aug 4, 2021

Can the 'commands' class include only base redis commands, by separating sentinel and cluster commands into their own command classes?
Then we can use multiple inheritance for special Redis clients and to ensure its API only includes its relevant commands

@chayim
Copy link
Contributor Author

chayim commented Aug 5, 2021

@barhsaul Great idea - I did that, after the 6.2.5 base docker upgrade. It still feels missing somehow given the parse_sentinel* helpers. Those might move as well 🤷

@chayim chayim requested a review from abrookins August 8, 2021 09:18
@chayim
Copy link
Contributor Author

chayim commented Aug 8, 2021

It looks like there are some great sentinel commands in #834 that we can also reference here. Once this is merged, I'd look at merging that in.

@chayim chayim mentioned this pull request Aug 8, 2021
Copy link
Contributor

@abrookins abrookins left a comment

Choose a reason for hiding this comment

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

This looks good to me and should help compose clients that add additional commands. 👍

One day I'd like to figure out how to define the logic for core commands in one place that we can use for both redis-py and aioredis-py, but that's for another day.

@chayim chayim merged commit 8ea26c4 into redis:master Aug 18, 2021
@chayim chayim deleted the ck-commandmig branch August 18, 2021 06:51
Andrew-Chen-Wang added a commit to aio-libs-abandoned/aioredis-py that referenced this pull request Oct 8, 2021
Migrating commands to a mixin (redis/redis-py#1534)

* Fixes #1136
* Added typing.py to store type annotations

Signed-off-by: Andrew-Chen-Wang <acwangpython@gmail.com>
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.

None yet

3 participants