File tree Expand file tree Collapse file tree 4 files changed +10
-2
lines changed
sqlx-postgres/src/connection Expand file tree Collapse file tree 4 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,10 @@ use super::worker::{Shared, Worker};
12
12
13
13
impl PgConnection {
14
14
pub ( crate ) async fn establish ( options : & PgConnectOptions ) -> Result < Self , Error > {
15
+ // A channel to communicate postgres notifications between the bg worker and a `PgListener`.
15
16
let ( notif_tx, notif_rx) = unbounded ( ) ;
17
+
18
+ // Shared state between the bg worker and the `PgConnection`
16
19
let shared = Shared :: new ( ) ;
17
20
18
21
// Upgrade to TLS if we were asked to and the server supports it
@@ -116,7 +119,7 @@ impl PgConnection {
116
119
}
117
120
118
121
BackendMessageFormat :: ReadyForQuery => {
119
- // Transaction status is updated in the bg worker.
122
+ // The transaction status is updated in the bg worker.
120
123
break ;
121
124
}
122
125
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ pub struct PgConnection {
40
40
}
41
41
42
42
pub struct PgConnectionInner {
43
+ // channel to the background worker
43
44
chan : UnboundedSender < IoRequest > ,
44
45
45
46
pub ( crate ) notifications : UnboundedReceiver < Notification > ,
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ use crate::{
7
7
PgDatabaseError ,
8
8
} ;
9
9
10
+ /// A temporary stream of responses sent from the background worker. The steam is stopped when
11
+ /// either a [ReadyForQuery] of [CopyInResponse] is received.
10
12
pub struct Pipe {
11
13
receiver : UnboundedReceiver < ReceivedMessage > ,
12
14
}
@@ -21,6 +23,7 @@ impl Pipe {
21
23
}
22
24
23
25
pub async fn recv_ready_for_query ( & mut self ) -> Result < ( ) , Error > {
26
+ // The transaction status is updated in the bg worker.
24
27
let _: ReadyForQuery = self . recv_expect ( ) . await ?;
25
28
Ok ( ( ) )
26
29
}
@@ -30,7 +33,7 @@ impl Pipe {
30
33
let message = self . recv ( ) . await ?;
31
34
32
35
if let BackendMessageFormat :: ReadyForQuery = message. format {
33
- let _ : ReadyForQuery = message . decode ( ) ? ;
36
+ // The transaction status is updated in the bg worker.
34
37
break ;
35
38
}
36
39
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub struct IoRequest {
10
10
pub data : Vec < u8 > ,
11
11
}
12
12
13
+ /// A buffer that contains encoded postgres messages, ready to be sent over the wire.
13
14
pub struct MessageBuf {
14
15
data : Vec < u8 > ,
15
16
}
You can’t perform that action at this time.
0 commit comments