Skip to content

Commit afd1b72

Browse files
committed
rustfmt
1 parent c67083e commit afd1b72

File tree

6 files changed

+27
-33
lines changed

6 files changed

+27
-33
lines changed

src/cmap/establish/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::{
1111
};
1212
use crate::{
1313
client::{auth::Credential, options::ServerApi},
14-
error::{ErrorKind, Error as MongoError},
14+
error::{Error as MongoError, ErrorKind},
1515
runtime::HttpClient,
1616
sdam::HandshakePhase,
1717
};
@@ -48,17 +48,20 @@ impl ConnectionEstablisher {
4848
pending_connection: PendingConnection,
4949
) -> std::result::Result<Connection, EstablishError> {
5050
let pool_gen = pending_connection.generation.clone();
51-
let mut connection = Connection::connect(pending_connection).await.map_err(|e| EstablishError::pre_hello(e, pool_gen.clone()))?;
51+
let mut connection = Connection::connect(pending_connection)
52+
.await
53+
.map_err(|e| EstablishError::pre_hello(e, pool_gen.clone()))?;
5254

53-
let handshake = self.handshaker.handshake(&mut connection).await.map_err(|e| EstablishError::pre_hello(e, pool_gen.clone()))?;
55+
let handshake = self
56+
.handshaker
57+
.handshake(&mut connection)
58+
.await
59+
.map_err(|e| EstablishError::pre_hello(e, pool_gen.clone()))?;
5460
let service_id = handshake.is_master_reply.command_response.service_id;
5561

5662
// If the handshake response had a `serviceId` field, this is a connection to a load
5763
// balancer and must derive its generation from the service_generations map.
58-
match (
59-
pool_gen,
60-
service_id,
61-
) {
64+
match (pool_gen, service_id) {
6265
(PoolGeneration::Normal(_), _) => {}
6366
(PoolGeneration::LoadBalanced(gen_map), Some(service_id)) => {
6467
connection.generation = ConnectionGeneration::LoadBalanced {
@@ -70,7 +73,8 @@ impl ConnectionEstablisher {
7073
return Err(EstablishError::post_hello(
7174
ErrorKind::Internal {
7275
message: "load-balanced mode mismatch".to_string(),
73-
}.into(),
76+
}
77+
.into(),
7478
connection.generation.clone(),
7579
));
7680
}
@@ -112,4 +116,4 @@ impl EstablishError {
112116
handshake_phase: HandshakePhase::PostHello { generation },
113117
}
114118
}
115-
}
119+
}

src/cmap/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use derivative::Derivative;
1616
pub use self::conn::ConnectionInfo;
1717
pub(crate) use self::{
1818
conn::{Command, Connection, RawCommand, RawCommandResponse, StreamDescription},
19-
establish::{EstablishError, handshake::Handshaker},
19+
establish::{handshake::Handshaker, EstablishError},
2020
status::PoolGenerationSubscriber,
2121
worker::PoolGeneration,
2222
};

src/sdam/description/topology/test/sdam.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,9 @@ async fn run_test(test_file: TestFile) {
284284
.unwrap_or(0);
285285
let conn_generation = ConnectionGeneration::Normal(conn_generation);
286286
let handshake_phase = match application_error.when {
287-
ErrorHandshakePhase::BeforeHandshakeCompletes => {
288-
HandshakePhase::PreHello {
289-
generation: pool_generation,
290-
}
291-
}
287+
ErrorHandshakePhase::BeforeHandshakeCompletes => HandshakePhase::PreHello {
288+
generation: pool_generation,
289+
},
292290
ErrorHandshakePhase::AfterHandshakeCompletes => {
293291
HandshakePhase::AfterCompletion {
294292
generation: conn_generation,

src/sdam/monitor.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,9 @@ impl UpdateMonitor {
241241
};
242242

243243
match update.into_message() {
244-
ServerUpdate::Error {
245-
error,
246-
} => {
244+
ServerUpdate::Error { error } => {
247245
topology
248-
.handle_application_error(
249-
error.cause,
250-
error.handshake_phase,
251-
&server,
252-
)
246+
.handle_application_error(error.cause, error.handshake_phase, &server)
253247
.await;
254248
}
255249
}

src/sdam/state/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,14 @@ impl Topology {
261261
}
262262
}
263263
// Pre-hello handshake errors are ignored in load-balanced mode.
264-
(PoolGeneration::LoadBalanced(_), PoolGeneration::LoadBalanced(_)) => return false,
264+
(PoolGeneration::LoadBalanced(_), PoolGeneration::LoadBalanced(_)) => {
265+
return false
266+
}
265267
_ => {} // TODO RUST-230 Log an error for mode mismatch.
266268
}
267269
}
268-
HandshakePhase::PostHello { generation } |
269-
HandshakePhase::AfterCompletion { generation, .. } => {
270+
HandshakePhase::PostHello { generation }
271+
| HandshakePhase::AfterCompletion { generation, .. } => {
270272
if generation.is_stale(&server.pool.generation()) {
271273
return false;
272274
}

src/sdam/state/server.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
cmap::{options::ConnectionPoolOptions, ConnectionPool, EstablishError},
99
options::{ClientOptions, ServerAddress},
1010
runtime::{AcknowledgedMessage, HttpClient},
11-
sdam::{monitor::Monitor},
11+
sdam::monitor::Monitor,
1212
};
1313

1414
/// Contains the state for a given server in the topology.
@@ -73,9 +73,7 @@ impl Server {
7373
/// TODO: add success cases from application handshakes.
7474
#[derive(Debug)]
7575
pub(crate) enum ServerUpdate {
76-
Error {
77-
error: EstablishError,
78-
},
76+
Error { error: EstablishError },
7977
}
8078

8179
#[derive(Debug)]
@@ -108,9 +106,7 @@ impl ServerUpdateSender {
108106
/// Update the server based on the given error.
109107
/// This will block until the topology has processed the error.
110108
pub(crate) async fn handle_error(&mut self, error: EstablishError) {
111-
let reason = ServerUpdate::Error {
112-
error,
113-
};
109+
let reason = ServerUpdate::Error { error };
114110

115111
let (message, callback) = AcknowledgedMessage::package(reason);
116112
// These only fails if the other ends hang up, which means the monitor is

0 commit comments

Comments
 (0)