Skip to content

Commit 39463c1

Browse files
committed
update to newer spec behavior
1 parent 4b4a346 commit 39463c1

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/sdam/topology.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,34 @@ impl TopologyWorker {
472472
}
473473

474474
/// Update the topology using the provided `ServerDescription`.
475-
async fn update_server(&mut self, sd: ServerDescription) -> bool {
476-
let server_type = sd.server_type;
477-
let server_address = sd.address.clone();
478-
475+
async fn update_server(&mut self, mut sd: ServerDescription) -> bool {
479476
let mut latest_state = self.borrow_latest_state().clone();
480477
let old_description = latest_state.description.clone();
481478

479+
if let Some(expected_name) = &self.options.repl_set_name {
480+
let got_name = sd.set_name();
481+
if latest_state.description.topology_type() == TopologyType::Single
482+
&& got_name.as_ref().map(|opt| opt.as_ref()) != Ok(Some(expected_name))
483+
{
484+
let got_display = match got_name {
485+
Ok(Some(s)) => format!("{:?}", s),
486+
Ok(None) => "<none>".to_string(),
487+
Err(s) => format!("<error: {}>", s),
488+
};
489+
// Mark server as unknown.
490+
sd = ServerDescription::new(
491+
sd.address,
492+
Some(Err(format!(
493+
"Connection string replicaSet name {:?} does not match actual name {}",
494+
expected_name, got_display,
495+
))),
496+
);
497+
}
498+
}
499+
500+
let server_type = sd.server_type;
501+
let server_address = sd.address.clone();
502+
482503
// TODO: RUST-1270 change this method to not return a result.
483504
let _ = latest_state.description.update(sd);
484505

0 commit comments

Comments
 (0)