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};
1212
1313impl PgConnection {
1414 pub ( crate ) async fn establish ( options : & PgConnectOptions ) -> Result < Self , Error > {
15+ // A channel to communicate postgres notifications between the bg worker and a `PgListener`.
1516 let ( notif_tx, notif_rx) = unbounded ( ) ;
17+
18+ // Shared state between the bg worker and the `PgConnection`
1619 let shared = Shared :: new ( ) ;
1720
1821 // Upgrade to TLS if we were asked to and the server supports it
@@ -116,7 +119,7 @@ impl PgConnection {
116119 }
117120
118121 BackendMessageFormat :: ReadyForQuery => {
119- // Transaction status is updated in the bg worker.
122+ // The transaction status is updated in the bg worker.
120123 break ;
121124 }
122125
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ pub struct PgConnection {
3939}
4040
4141pub struct PgConnectionInner {
42+ // channel to the background worker
4243 chan : UnboundedSender < IoRequest > ,
4344
4445 pub ( crate ) notifications : UnboundedReceiver < Notification > ,
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ use crate::{
77 PgDatabaseError ,
88} ;
99
10+ /// A temporary stream of responses sent from the background worker. The steam is stopped when
11+ /// either a [ReadyForQuery] of [CopyInResponse] is received.
1012pub struct Pipe {
1113 receiver : UnboundedReceiver < ReceivedMessage > ,
1214}
@@ -21,6 +23,7 @@ impl Pipe {
2123 }
2224
2325 pub async fn recv_ready_for_query ( & mut self ) -> Result < ( ) , Error > {
26+ // The transaction status is updated in the bg worker.
2427 let _: ReadyForQuery = self . recv_expect ( ) . await ?;
2528 Ok ( ( ) )
2629 }
@@ -30,7 +33,7 @@ impl Pipe {
3033 let message = self . recv ( ) . await ?;
3134
3235 if let BackendMessageFormat :: ReadyForQuery = message. format {
33- let _ : ReadyForQuery = message . decode ( ) ? ;
36+ // The transaction status is updated in the bg worker.
3437 break ;
3538 }
3639 }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub struct IoRequest {
1010 pub data : Vec < u8 > ,
1111}
1212
13+ /// A buffer that contains encoded postgres messages, ready to be sent over the wire.
1314pub struct MessageBuf {
1415 data : Vec < u8 > ,
1516}
You can’t perform that action at this time.
0 commit comments