-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unnamable types #1094
Fix unnamable types #1094
Changes from all commits
f2b358a
c5122de
b6fc7d9
6439b32
d7ba747
7f7f2d0
14ff415
ef2bba2
8a3e60d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,5 @@ full-serialization = [ | |
] | ||
|
||
[lints.rust] | ||
unnameable_types = "warn" | ||
unreachable_pub = "warn" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,5 @@ quote = "1.0" | |
proc-macro2 = "1.0" | ||
|
||
[lints.rust] | ||
unnameable_types = "warn" | ||
unreachable_pub = "warn" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ use tracing::{debug, warn}; | |
use uuid::Uuid; | ||
|
||
use super::locator::tablets::{RawTablet, Tablet, TabletsInfo}; | ||
use super::node::{KnownNode, NodeAddr}; | ||
use super::node::{InternalKnownNode, NodeAddr}; | ||
use super::NodeRef; | ||
|
||
use super::locator::ReplicaLocator; | ||
|
@@ -59,12 +59,6 @@ impl<'a> std::fmt::Debug for ClusterNeatDebug<'a> { | |
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Datacenter { | ||
pub nodes: Vec<Arc<Node>>, | ||
pub rack_count: usize, | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct ClusterData { | ||
pub(crate) known_peers: HashMap<Uuid, Arc<Node>>, // Invariant: nonempty after Cluster::new() | ||
|
@@ -145,7 +139,7 @@ struct UseKeyspaceRequest { | |
|
||
impl Cluster { | ||
pub(crate) async fn new( | ||
known_nodes: Vec<KnownNode>, | ||
known_nodes: Vec<InternalKnownNode>, | ||
pool_config: PoolConfig, | ||
keyspaces_to_fetch: Vec<String>, | ||
fetch_schema_metadata: bool, | ||
|
@@ -257,18 +251,6 @@ impl Cluster { | |
} | ||
|
||
impl ClusterData { | ||
// Updates information about rack count in each datacenter | ||
fn update_rack_count(datacenters: &mut HashMap<String, Datacenter>) { | ||
for datacenter in datacenters.values_mut() { | ||
datacenter.rack_count = datacenter | ||
.nodes | ||
.iter() | ||
.filter_map(|node| node.rack.as_ref()) | ||
.unique() | ||
.count(); | ||
} | ||
} | ||
|
||
pub(crate) async fn wait_until_all_pools_are_initialized(&self) { | ||
for node in self.locator.unique_nodes_in_global_ring().iter() { | ||
node.wait_until_pool_initialized().await; | ||
|
@@ -289,7 +271,6 @@ impl ClusterData { | |
let mut new_known_peers: HashMap<Uuid, Arc<Node>> = | ||
HashMap::with_capacity(metadata.peers.len()); | ||
let mut ring: Vec<(Token, Arc<Node>)> = Vec::new(); | ||
let mut datacenters: HashMap<String, Datacenter> = HashMap::new(); | ||
|
||
for peer in metadata.peers { | ||
// Take existing Arc<Node> if possible, otherwise create new one | ||
|
@@ -325,19 +306,6 @@ impl ClusterData { | |
|
||
new_known_peers.insert(peer_host_id, node.clone()); | ||
|
||
if let Some(dc) = &node.datacenter { | ||
match datacenters.get_mut(dc) { | ||
Some(v) => v.nodes.push(node.clone()), | ||
None => { | ||
let v = Datacenter { | ||
nodes: vec![node.clone()], | ||
rack_count: 0, | ||
}; | ||
datacenters.insert(dc.clone(), v); | ||
} | ||
} | ||
} | ||
|
||
for token in peer_tokens { | ||
Comment on lines
308
to
309
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but... |
||
ring.push((token, node.clone())); | ||
} | ||
|
@@ -384,8 +352,6 @@ impl ClusterData { | |
) | ||
} | ||
|
||
Self::update_rack_count(&mut datacenters); | ||
|
||
let keyspaces = metadata.keyspaces; | ||
Comment on lines
354
to
355
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...was that really pointless?! I can't believe it has always been... Could you please locate the commit that made There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code was introduced in this commit: 8d82b04#diff-fc8ab4fd7742b17e4767ade6844fd697e5a7b0050bbadb414f52d19f6245bbac (PR: #172 ) Then the field in ClusterData was removed by the same author 2 years later: 0db57c1 - but the calculation in ClusterData::new remained, introducing uselessness. PR: #612 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure that even thought there was no useless calculation before #612 this API was still useless because |
||
let (locator, keyspaces) = tokio::task::spawn_blocking(move || { | ||
let keyspace_strategies = keyspaces.values().map(|ks| &ks.strategy); | ||
|
@@ -409,25 +375,6 @@ impl ClusterData { | |
&self.keyspaces | ||
} | ||
Lorak-mmk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Access datacenter details collected by the driver | ||
/// Returned `HashMap` is indexed by names of datacenters | ||
pub fn get_datacenters_info(&self) -> HashMap<String, Datacenter> { | ||
self.locator | ||
.datacenter_names() | ||
.iter() | ||
.map(|dc_name| { | ||
let nodes = self | ||
.locator | ||
.unique_nodes_in_datacenter_ring(dc_name) | ||
.unwrap() | ||
.to_vec(); | ||
let rack_count = nodes.iter().map(|node| node.rack.as_ref()).unique().count(); | ||
|
||
(dc_name.clone(), Datacenter { nodes, rack_count }) | ||
}) | ||
.collect() | ||
} | ||
|
||
/// Access details about nodes known to the driver | ||
wprzytula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub fn get_nodes_info(&self) -> &[Arc<Node>] { | ||
self.locator.unique_nodes_in_global_ring() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,10 @@ use openssl::ssl::SslContext; | |
use tracing::warn; | ||
|
||
mod sealed { | ||
// This is a sealed trait - its whole purpose is to be unnameable. | ||
// This means we need to disable the check. | ||
#[allow(unknown_lints)] // Rust 1.66 doesn't know this lint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer support Rust 1.66. Does 1.70 know this lint? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately not - it was introduced in 1.79, so we would need to bump MSRV much higher for that. |
||
#[allow(unnameable_types)] | ||
pub trait Sealed {} | ||
} | ||
pub trait SessionBuilderKind: sealed::Sealed + Clone {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow.