Skip to content

Commit

Permalink
cluster: remove argument from read_from_replicas & add deprecated not…
Browse files Browse the repository at this point in the history
…e to readonly
  • Loading branch information
utkarshgupta137 committed Jun 26, 2022
1 parent ec2a3d1 commit a36310f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion benches/bench_cluster.rs
Expand Up @@ -87,7 +87,7 @@ fn bench_cluster_setup(c: &mut Criterion) {
#[allow(dead_code)]
fn bench_cluster_read_from_replicas_setup(c: &mut Criterion) {
let cluster = TestClusterContext::new_with_cluster_client_builder(6, 1, |builder| {
builder.read_from_replicas(true)
builder.read_from_replicas()
});
cluster.wait_for_cluster_up();

Expand Down
13 changes: 7 additions & 6 deletions src/cluster_client.rs
Expand Up @@ -54,15 +54,16 @@ impl ClusterClientBuilder {
///
/// If True, then read queries will go to the replica nodes & write queries will go to the
/// primary nodes. If there are no replica nodes, then all queries will go to the primary nodes.
pub fn read_from_replicas(mut self, read_from_replicas: bool) -> ClusterClientBuilder {
self.read_from_replicas = read_from_replicas;
pub fn read_from_replicas(mut self) -> ClusterClientBuilder {
self.read_from_replicas = true;
self
}

/// Use `read_from_replicas`.
#[deprecated(since = "0.22.0")]
pub fn readonly(self, read_from_replicas: bool) -> ClusterClientBuilder {
self.read_from_replicas(read_from_replicas)
/// Use `read_from_replicas()`.
#[deprecated(since = "0.22.0", note = "Use read_from_replicas()")]
pub fn readonly(mut self, read_from_replicas: bool) -> ClusterClientBuilder {
self.read_from_replicas = read_from_replicas;
self
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cluster.rs
Expand Up @@ -58,7 +58,7 @@ fn test_cluster_with_bad_password() {
#[test]
fn test_cluster_read_from_replicas() {
let cluster = TestClusterContext::new_with_cluster_client_builder(6, 1, |builder| {
builder.read_from_replicas(true)
builder.read_from_replicas()
});
let mut con = cluster.connection();

Expand Down

0 comments on commit a36310f

Please sign in to comment.