Skip to content

Commit f21a3d8

Browse files
authored
Add server login stat; refactor for better naming (#34)
1 parent f805b43 commit f21a3d8

File tree

2 files changed

+95
-80
lines changed

2 files changed

+95
-80
lines changed

src/pool.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,31 @@ impl ManageConnection for ServerPool {
351351
self.address, self.user.name
352352
);
353353

354-
Server::startup(
354+
// Put a temporary process_id into the stats
355+
// for server login.
356+
let process_id = rand::random::<i32>();
357+
self.stats.server_login(process_id);
358+
359+
match Server::startup(
355360
&self.address,
356361
&self.user,
357362
&self.database,
358363
self.client_server_map.clone(),
359364
self.stats.clone(),
360365
)
361366
.await
367+
{
368+
Ok(conn) => {
369+
// Remove the temporary process_id from the stats.
370+
self.stats.server_disconnecting(process_id);
371+
Ok(conn)
372+
}
373+
Err(err) => {
374+
// Remove the temporary process_id from the stats.
375+
self.stats.server_disconnecting(process_id);
376+
Err(err)
377+
}
378+
}
362379
}
363380

364381
/// Determines if the connection is still connected to the database.

0 commit comments

Comments
 (0)