Skip to content

Commit

Permalink
CassandraNode new method (#832)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Kent <rubickent@gmail.com>
  • Loading branch information
conorbros and rukai committed Sep 29, 2022
1 parent ab63447 commit 3583a92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
16 changes: 16 additions & 0 deletions shotover-proxy/src/transforms/cassandra/sink_cluster/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ pub struct CassandraNode {
}

impl CassandraNode {
pub fn new(
address: SocketAddr,
rack: String,
tokens: Vec<Murmur3Token>,
host_id: Uuid,
) -> Self {
Self {
address,
rack,
tokens,
host_id,
outbound: None,
is_up: true,
}
}

pub async fn get_connection(
&mut self,
connection_factory: &ConnectionFactory,
Expand Down
17 changes: 4 additions & 13 deletions shotover-proxy/src/transforms/cassandra/sink_cluster/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,7 @@ mod system_local {
return Err(anyhow!("system.local.rack not a varchar"));
};

Ok(CassandraNode {
address,
rack,
tokens,
outbound: None,
host_id,
is_up: true,
})
Ok(CassandraNode::new(address, rack, tokens, host_id))
})
.collect(),
operation => Err(anyhow!(
Expand Down Expand Up @@ -400,14 +393,12 @@ mod system_peers {
9042
};

Ok(CassandraNode {
address: SocketAddr::new(ip, port.try_into()?),
Ok(CassandraNode::new(
SocketAddr::new(ip, port.try_into()?),
rack,
tokens,
outbound: None,
host_id,
is_up: true,
})
))
})
.collect(),
operation => Err(anyhow!(
Expand Down

0 comments on commit 3583a92

Please sign in to comment.