@@ -39,10 +39,16 @@ pub(crate) use wire::next_request_id;
39
39
40
40
/// User-facing information about a connection to the database.
41
41
#[ derive( Clone , Debug , Serialize ) ]
42
+ #[ serde( rename_all = "camelCase" ) ]
43
+ #[ non_exhaustive]
42
44
pub struct ConnectionInfo {
43
45
/// A driver-generated identifier that uniquely identifies the connection.
44
46
pub id : u32 ,
45
47
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
+
46
52
/// The address that the connection is connected to.
47
53
pub address : ServerAddress ,
48
54
}
@@ -51,7 +57,11 @@ pub struct ConnectionInfo {
51
57
#[ derive( Derivative ) ]
52
58
#[ derivative( Debug ) ]
53
59
pub ( crate ) struct Connection {
60
+ /// Driver-generated ID for the connection.
54
61
pub ( super ) id : u32 ,
62
+ /// Server-generated ID for the connection.
63
+ pub ( crate ) server_id : Option < i32 > ,
64
+
55
65
pub ( crate ) address : ServerAddress ,
56
66
pub ( crate ) generation : ConnectionGeneration ,
57
67
@@ -109,6 +119,7 @@ impl Connection {
109
119
110
120
let conn = Self {
111
121
id,
122
+ server_id : None ,
112
123
generation : ConnectionGeneration :: Normal ( generation) ,
113
124
pool_manager : None ,
114
125
command_executing : false ,
@@ -174,6 +185,7 @@ impl Connection {
174
185
pub ( crate ) fn info ( & self ) -> ConnectionInfo {
175
186
ConnectionInfo {
176
187
id : self . id ,
188
+ server_id : self . server_id ,
177
189
address : self . address . clone ( ) ,
178
190
}
179
191
}
@@ -370,6 +382,7 @@ impl Connection {
370
382
fn take ( & mut self ) -> Connection {
371
383
Connection {
372
384
id : self . id ,
385
+ server_id : self . server_id ,
373
386
address : self . address . clone ( ) ,
374
387
generation : self . generation . clone ( ) ,
375
388
stream : std:: mem:: replace ( & mut self . stream , AsyncStream :: Null ) ,
0 commit comments