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

[1/5] cluster: implement proper builder pattern & minor refactor #669

Merged
merged 4 commits into from Aug 31, 2022

Conversation

utkarshgupta137
Copy link
Contributor

@utkarshgupta137 utkarshgupta137 commented Aug 23, 2022

Most of the crates in the Rust ecosystem use builder() & build() for client & builder as well as new() for both of them. Currently, the redis crate uses the unintuitive open() methods for the same.
With this PR, I've changed the cluster client to follow the proper builder pattern and redirect the old methods to the new ones.

Also refactored the cluster client in 2 main ways:

  • Moved the build() method from the client to the builder & made it public
  • Create a crate-level struct ClusterParams to hold all the params inside a single struct instead of multiple fields in the main struct
    • This struct will be used in the later PRs to pass cluster params to & inside the ClusterConnection impl

In addition, improved the documentation as I saw fit.

@utkarshgupta137 utkarshgupta137 changed the title cluster: implement proper builder pattern & minor refactor [1/5] cluster: implement proper builder pattern & minor refactor Aug 23, 2022
redis/src/cluster.rs Outdated Show resolved Hide resolved
@jaymell jaymell requested a review from djc August 25, 2022 03:12
redis/src/cluster_client.rs Outdated Show resolved Hide resolved
redis/src/cluster_client.rs Outdated Show resolved Hide resolved
redis/src/cluster_client.rs Show resolved Hide resolved
redis/src/cluster.rs Outdated Show resolved Hide resolved
redis/src/cluster_client.rs Outdated Show resolved Hide resolved
redis/src/cluster_client.rs Outdated Show resolved Hide resolved
@utkarshgupta137 utkarshgupta137 force-pushed the cluster_builder branch 2 times, most recently from 9e3acae to 1d04be5 Compare August 30, 2022 22:39
@utkarshgupta137
Copy link
Contributor Author

@jaymell @djc It's failing on older versions due to an unrelated crate error:

error: package `async-global-executor v2.3.0` cannot be built because it requires rustc 1.59 or newer, while the currently active rustc version is 1.57.0

redis/src/cluster_client.rs Show resolved Hide resolved
redis/src/cluster_client.rs Show resolved Hide resolved
redis/src/cluster.rs Show resolved Hide resolved
redis/src/cluster_client.rs Outdated Show resolved Hide resolved
@djc
Copy link
Contributor

djc commented Aug 31, 2022

This is much better! A few more minor changes. Please add a separate commit that bumps the MSRV to 1.59.

@utkarshgupta137
Copy link
Contributor Author

This is much better! A few more minor changes. Please add a separate commit that bumps the MSRV to 1.59.

MSRV change is entirely unrelated to this PR. I've created a separate PR: #673

@utkarshgupta137
Copy link
Contributor Author

@djc I've added the bump MSRV commit to this PR for testing purposes, but please merge #673 first.

- move build method to builder
- move open methods to the bottom
- implement proper builder pattern by adding `new` & `builder` methods to ClusterClient and `new` & `build` methods to ClusterClientBuilder
- deprecate & redirect `open` methods for ClusterClient & ClusterClientBuilder
- this is to simplify passing multiple params to & inside ClusterConnection impl
redis/src/cluster_client.rs Outdated Show resolved Hide resolved
@djc
Copy link
Contributor

djc commented Aug 31, 2022

Okay, so please rebase and self-review part 2 to have small commits and align with the other feedback I've given so far, this has taken a lot of time.

@utkarshgupta137
Copy link
Contributor Author

Sure, waiting for you to merge this.

@djc djc merged commit c1ab77f into redis-rs:main Aug 31, 2022
@utkarshgupta137 utkarshgupta137 deleted the cluster_builder branch August 31, 2022 12:30
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