File tree Expand file tree Collapse file tree
pgdog/src/frontend/client/query_engine Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22#![ allow( unused_variables, dead_code) ]
33use super :: * ;
44
5+ #[ derive( Debug ) ]
56pub struct QueryEngineHooks ;
67
8+ impl Default for QueryEngineHooks {
9+ fn default ( ) -> Self {
10+ Self :: new ( )
11+ }
12+ }
13+
714impl QueryEngineHooks {
815 pub ( super ) fn new ( ) -> Self {
916 Self { }
@@ -16,6 +23,14 @@ impl QueryEngineHooks {
1623 Ok ( ( ) )
1724 }
1825
26+ pub ( super ) fn after_connected (
27+ & mut self ,
28+ context : & mut QueryEngineContext < ' _ > ,
29+ backend : & Connection ,
30+ ) -> Result < ( ) , Error > {
31+ Ok ( ( ) )
32+ }
33+
1934 pub ( super ) fn after_execution (
2035 & mut self ,
2136 context : & mut QueryEngineContext < ' _ > ,
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ pub struct QueryEngine {
5353 two_pc : TwoPc ,
5454 notify_buffer : NotifyBuffer ,
5555 pending_explain : Option < ExplainResponseState > ,
56+ hooks : QueryEngineHooks ,
5657}
5758
5859impl QueryEngine {
@@ -72,6 +73,7 @@ impl QueryEngine {
7273 backend,
7374 client_id : comms. client_id ( ) ,
7475 comms : comms. clone ( ) ,
76+ hooks : QueryEngineHooks :: new ( ) ,
7577 #[ cfg( test) ]
7678 test_mode : true ,
7779 #[ cfg( not( test) ) ]
@@ -125,8 +127,7 @@ impl QueryEngine {
125127 return Ok ( ( ) ) ;
126128 }
127129
128- let mut hooks = QueryEngineHooks :: new ( ) ;
129- hooks. before_execution ( context) ?;
130+ self . hooks . before_execution ( context) ?;
130131
131132 // Queue up request to mirrors, if any.
132133 // Do this before sending query to actual server
@@ -223,7 +224,7 @@ impl QueryEngine {
223224 command => self . unknown_command ( context, command. clone ( ) ) . await ?,
224225 }
225226
226- hooks. after_execution ( context) ?;
227+ self . hooks . after_execution ( context) ?;
227228
228229 if context. in_error ( ) {
229230 self . backend . mirror_clear ( ) ;
Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ impl QueryEngine {
6868 }
6969 }
7070
71+ self . hooks . after_connected ( context, & self . backend ) ?;
72+
7173 self . backend
7274 . handle_client_request ( context. client_request , & mut self . router , self . streaming )
7375 . await ?;
You can’t perform that action at this time.
0 commit comments