Skip to content

Commit b678d0d

Browse files
committed
Move SingleTargetLBP to common/utils.rs
Moves `SingleTargetLBP` used by `integration/tablets.rs` to `common/utils.rs` Code is identical except added `pub(crate)` to the struct and its `target` field. Moving it to allow usage in `integration/caching_session.rs` from subsequent commit and in other tests.
1 parent a253772 commit b678d0d

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

scylla/tests/common/utils.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,31 @@ impl PerformDDL for CachingSession {
300300
self.execute_unpaged(query, &[]).await.map(|_| ())
301301
}
302302
}
303+
304+
#[derive(Debug)]
305+
#[allow(dead_code)]
306+
pub(crate) struct SingleTargetLBP {
307+
pub(crate) target: (Arc<scylla::cluster::Node>, Option<u32>),
308+
}
309+
310+
impl LoadBalancingPolicy for SingleTargetLBP {
311+
fn pick<'a>(
312+
&'a self,
313+
_query: &'a RoutingInfo,
314+
_cluster: &'a ClusterState,
315+
) -> Option<(NodeRef<'a>, Option<u32>)> {
316+
Some((&self.target.0, self.target.1))
317+
}
318+
319+
fn fallback<'a>(
320+
&'a self,
321+
_query: &'a RoutingInfo,
322+
_cluster: &'a ClusterState,
323+
) -> FallbackPlan<'a> {
324+
Box::new(std::iter::empty())
325+
}
326+
327+
fn name(&self) -> String {
328+
"SingleTargetLBP".to_owned()
329+
}
330+
}

scylla/tests/integration/tablets.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::sync::Arc;
22

3+
use crate::utils::SingleTargetLBP;
34
use crate::utils::{
45
scylla_supports_tablets, setup_tracing, test_with_3_node_cluster, unique_keyspace_name,
56
PerformDDL,
@@ -12,10 +13,6 @@ use scylla::client::execution_profile::ExecutionProfile;
1213
use scylla::client::session::Session;
1314
use scylla::cluster::ClusterState;
1415
use scylla::cluster::Node;
15-
use scylla::cluster::NodeRef;
16-
use scylla::policies::load_balancing::FallbackPlan;
17-
use scylla::policies::load_balancing::LoadBalancingPolicy;
18-
use scylla::policies::load_balancing::RoutingInfo;
1916
use scylla::prepared_statement::PreparedStatement;
2017
use scylla::query::Query;
2118
use scylla::response::query_result::QueryResult;
@@ -156,33 +153,6 @@ fn calculate_key_per_tablet(tablets: &[Tablet], prepared: &PreparedStatement) ->
156153
value_lists
157154
}
158155

159-
#[derive(Debug)]
160-
struct SingleTargetLBP {
161-
target: (Arc<Node>, Option<u32>),
162-
}
163-
164-
impl LoadBalancingPolicy for SingleTargetLBP {
165-
fn pick<'a>(
166-
&'a self,
167-
_query: &'a RoutingInfo,
168-
_cluster: &'a ClusterState,
169-
) -> Option<(NodeRef<'a>, Option<u32>)> {
170-
Some((&self.target.0, self.target.1))
171-
}
172-
173-
fn fallback<'a>(
174-
&'a self,
175-
_query: &'a RoutingInfo,
176-
_cluster: &'a ClusterState,
177-
) -> FallbackPlan<'a> {
178-
Box::new(std::iter::empty())
179-
}
180-
181-
fn name(&self) -> String {
182-
"SingleTargetLBP".to_owned()
183-
}
184-
}
185-
186156
async fn send_statement_everywhere(
187157
session: &Session,
188158
cluster: &ClusterState,

0 commit comments

Comments
 (0)