Skip to content

Commit 533fac4

Browse files
committed
Filter that node is alive
1 parent 146655e commit 533fac4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

scylla/src/transport/load_balancing/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl DefaultPolicy {
594594
vec.into_iter()
595595
}
596596

597-
fn is_alive(node: &NodeRef<'_>) -> bool {
597+
pub(crate) fn is_alive(node: &NodeRef<'_>) -> bool {
598598
// For now, we leave this as stub, until we have time to improve node events.
599599
// node.is_enabled() && !node.is_down()
600600
node.is_enabled()

scylla/src/transport/load_balancing/enforce_node.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
use super::{FallbackPlan, LoadBalancingPolicy, NodeRef, RoutingInfo};
1+
use super::{DefaultPolicy, FallbackPlan, LoadBalancingPolicy, NodeRef, RoutingInfo};
22
use crate::transport::{cluster::ClusterData, Node};
33
use std::sync::Arc;
44

5+
/// This policy will always return the same node, unless it is not available anymore, in which case it will
6+
/// fallback to the provided policy.
57
#[derive(Debug)]
68
pub struct EnforceTargetNodePolicy {
79
target_node: uuid::Uuid,
@@ -21,6 +23,7 @@ impl LoadBalancingPolicy for EnforceTargetNodePolicy {
2123
cluster
2224
.known_peers
2325
.get(&self.target_node)
26+
.filter(DefaultPolicy::is_alive)
2427
.or_else(|| self.fallback.pick(query, cluster))
2528
}
2629

0 commit comments

Comments
 (0)