Skip to content

Commit

Permalink
retry_policy: remove clone_boxed() method from RetryPolicy trait
Browse files Browse the repository at this point in the history
Again, from now on we will prefer storing dyn RetryPolicy behind
an Arc. There is no need for `clone_boxed` method anymore.

Removed `impl Clone for Box<dyn RetryPolicy>`
  • Loading branch information
muzarski committed Oct 24, 2024
1 parent fc4c8de commit c958c9b
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 28 deletions.
4 changes: 0 additions & 4 deletions scylla/src/transport/downgrading_consistency_retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ impl RetryPolicy for DowngradingConsistencyRetryPolicy {
fn new_session(&self) -> Box<dyn RetrySession> {
Box::new(DowngradingConsistencyRetrySession::new())
}

fn clone_boxed(&self) -> Box<dyn RetryPolicy> {
Box::new(DowngradingConsistencyRetryPolicy)
}
}

pub struct DowngradingConsistencyRetrySession {
Expand Down
17 changes: 0 additions & 17 deletions scylla/src/transport/retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ pub enum RetryDecision {
pub trait RetryPolicy: std::fmt::Debug + Send + Sync {
/// Called for each new query, starts a session of deciding about retries
fn new_session(&self) -> Box<dyn RetrySession>;

/// Used to clone this RetryPolicy
fn clone_boxed(&self) -> Box<dyn RetryPolicy>;
}

impl Clone for Box<dyn RetryPolicy> {
fn clone(&self) -> Box<dyn RetryPolicy> {
self.clone_boxed()
}
}

/// Used throughout a single query to decide when to retry it
Expand Down Expand Up @@ -71,10 +62,6 @@ impl RetryPolicy for FallthroughRetryPolicy {
fn new_session(&self) -> Box<dyn RetrySession> {
Box::new(FallthroughRetrySession)
}

fn clone_boxed(&self) -> Box<dyn RetryPolicy> {
Box::new(FallthroughRetryPolicy)
}
}

impl RetrySession for FallthroughRetrySession {
Expand Down Expand Up @@ -106,10 +93,6 @@ impl RetryPolicy for DefaultRetryPolicy {
fn new_session(&self) -> Box<dyn RetrySession> {
Box::new(DefaultRetrySession::new())
}

fn clone_boxed(&self) -> Box<dyn RetryPolicy> {
Box::new(DefaultRetryPolicy)
}
}

pub struct DefaultRetrySession {
Expand Down
3 changes: 0 additions & 3 deletions scylla/src/transport/session_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2708,9 +2708,6 @@ async fn test_iter_works_when_retry_policy_returns_ignore_write_error() {
fn new_session(&self) -> Box<dyn RetrySession> {
Box::new(MyRetrySession(self.0.clone()))
}
fn clone_boxed(&self) -> Box<dyn RetryPolicy> {
Box::new(MyRetryPolicy(self.0.clone()))
}
}

struct MyRetrySession(Arc<AtomicBool>);
Expand Down
4 changes: 0 additions & 4 deletions scylla/tests/integration/execution_profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ impl<const NODE: u8> RetryPolicy for BoundToPredefinedNodePolicy<NODE> {
self.report_node(Report::RetryPolicy);
Box::new(self.clone())
}

fn clone_boxed(&self) -> Box<dyn RetryPolicy> {
Box::new(self.clone())
}
}

impl<const NODE: u8> RetrySession for BoundToPredefinedNodePolicy<NODE> {
Expand Down

0 comments on commit c958c9b

Please sign in to comment.