@@ -39,10 +39,16 @@ pub(crate) use wire::next_request_id;
3939
4040/// User-facing information about a connection to the database.
4141#[ derive( Clone , Debug , Serialize ) ]
42+ #[ serde( rename_all = "camelCase" ) ]
43+ #[ non_exhaustive]
4244pub struct ConnectionInfo {
4345 /// A driver-generated identifier that uniquely identifies the connection.
4446 pub id : u32 ,
4547
48+ /// A server-generated identifier that uniquely identifies the connection. Available on server
49+ /// versions 4.2+. This may be used to correlate driver connections with server logs.
50+ pub server_id : Option < i32 > ,
51+
4652 /// The address that the connection is connected to.
4753 pub address : ServerAddress ,
4854}
@@ -51,7 +57,11 @@ pub struct ConnectionInfo {
5157#[ derive( Derivative ) ]
5258#[ derivative( Debug ) ]
5359pub ( crate ) struct Connection {
60+ /// Driver-generated ID for the connection.
5461 pub ( super ) id : u32 ,
62+ /// Server-generated ID for the connection.
63+ pub ( crate ) server_id : Option < i32 > ,
64+
5565 pub ( crate ) address : ServerAddress ,
5666 pub ( crate ) generation : ConnectionGeneration ,
5767
@@ -109,6 +119,7 @@ impl Connection {
109119
110120 let conn = Self {
111121 id,
122+ server_id : None ,
112123 generation : ConnectionGeneration :: Normal ( generation) ,
113124 pool_manager : None ,
114125 command_executing : false ,
@@ -174,6 +185,7 @@ impl Connection {
174185 pub ( crate ) fn info ( & self ) -> ConnectionInfo {
175186 ConnectionInfo {
176187 id : self . id ,
188+ server_id : self . server_id ,
177189 address : self . address . clone ( ) ,
178190 }
179191 }
@@ -370,6 +382,7 @@ impl Connection {
370382 fn take ( & mut self ) -> Connection {
371383 Connection {
372384 id : self . id ,
385+ server_id : self . server_id ,
373386 address : self . address . clone ( ) ,
374387 generation : self . generation . clone ( ) ,
375388 stream : std:: mem:: replace ( & mut self . stream , AsyncStream :: Null ) ,
0 commit comments