Skip to content

Commit

Permalink
Filter that node is alive
Browse files Browse the repository at this point in the history
  • Loading branch information
Ten0 committed Jul 2, 2023
1 parent 146655e commit 533fac4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scylla/src/transport/load_balancing/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ impl DefaultPolicy {
vec.into_iter()
}

fn is_alive(node: &NodeRef<'_>) -> bool {
pub(crate) fn is_alive(node: &NodeRef<'_>) -> bool {
// For now, we leave this as stub, until we have time to improve node events.
// node.is_enabled() && !node.is_down()
node.is_enabled()
Expand Down
5 changes: 4 additions & 1 deletion scylla/src/transport/load_balancing/enforce_node.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::{FallbackPlan, LoadBalancingPolicy, NodeRef, RoutingInfo};
use super::{DefaultPolicy, FallbackPlan, LoadBalancingPolicy, NodeRef, RoutingInfo};
use crate::transport::{cluster::ClusterData, Node};
use std::sync::Arc;

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

Expand Down

0 comments on commit 533fac4

Please sign in to comment.