@@ -472,7 +472,7 @@ impl Default for SessionConfig {
472472 }
473473}
474474
475- pub ( crate ) enum RunQueryResult < ResT > {
475+ pub ( crate ) enum RunRequestResult < ResT > {
476476 IgnoredWriteError ,
477477 Completed ( ResT ) ,
478478}
@@ -1203,8 +1203,8 @@ where
12031203
12041204 let span = RequestSpan :: new_query ( & query. contents ) ;
12051205 let span_ref = & span;
1206- let run_query_result = self
1207- . run_query (
1206+ let run_request_result = self
1207+ . run_request (
12081208 statement_info,
12091209 & query. config ,
12101210 execution_profile,
@@ -1257,13 +1257,13 @@ where
12571257 . instrument ( span. span ( ) . clone ( ) )
12581258 . await ?;
12591259
1260- let response = match run_query_result {
1261- RunQueryResult :: IgnoredWriteError => NonErrorQueryResponse {
1260+ let response = match run_request_result {
1261+ RunRequestResult :: IgnoredWriteError => NonErrorQueryResponse {
12621262 response : NonErrorResponse :: Result ( result:: Result :: Void ) ,
12631263 tracing_id : None ,
12641264 warnings : Vec :: new ( ) ,
12651265 } ,
1266- RunQueryResult :: Completed ( response) => response,
1266+ RunRequestResult :: Completed ( response) => response,
12671267 } ;
12681268
12691269 self . handle_set_keyspace_response ( & response) . await ?;
@@ -1526,8 +1526,8 @@ where
15261526 }
15271527 }
15281528
1529- let run_query_result : RunQueryResult < NonErrorQueryResponse > = self
1530- . run_query (
1529+ let run_request_result : RunRequestResult < NonErrorQueryResponse > = self
1530+ . run_request (
15311531 statement_info,
15321532 & prepared. config ,
15331533 execution_profile,
@@ -1558,13 +1558,13 @@ where
15581558 . instrument ( span. span ( ) . clone ( ) )
15591559 . await ?;
15601560
1561- let response = match run_query_result {
1562- RunQueryResult :: IgnoredWriteError => NonErrorQueryResponse {
1561+ let response = match run_request_result {
1562+ RunRequestResult :: IgnoredWriteError => NonErrorQueryResponse {
15631563 response : NonErrorResponse :: Result ( result:: Result :: Void ) ,
15641564 tracing_id : None ,
15651565 warnings : Vec :: new ( ) ,
15661566 } ,
1567- RunQueryResult :: Completed ( response) => response,
1567+ RunRequestResult :: Completed ( response) => response,
15681568 } ;
15691569
15701570 self . handle_set_keyspace_response ( & response) . await ?;
@@ -1650,8 +1650,8 @@ where
16501650
16511651 let span = RequestSpan :: new_batch ( ) ;
16521652
1653- let run_query_result = self
1654- . run_query (
1653+ let run_request_result = self
1654+ . run_request (
16551655 statement_info,
16561656 & batch. config ,
16571657 execution_profile,
@@ -1678,9 +1678,9 @@ where
16781678 . instrument ( span. span ( ) . clone ( ) )
16791679 . await ?;
16801680
1681- let result = match run_query_result {
1682- RunQueryResult :: IgnoredWriteError => QueryResult :: mock_empty ( ) ,
1683- RunQueryResult :: Completed ( result) => {
1681+ let result = match run_request_result {
1682+ RunRequestResult :: IgnoredWriteError => QueryResult :: mock_empty ( ) ,
1683+ RunRequestResult :: Completed ( result) => {
16841684 span. record_result_fields ( & result) ;
16851685 result
16861686 }
@@ -1916,26 +1916,27 @@ where
19161916 Ok ( Some ( tracing_info) )
19171917 }
19181918
1919- // This method allows to easily run a query using load balancing, retry policy etc.
1920- // Requires some information about the query and a closure.
1921- // The closure is used to do the query itself on a connection.
1922- // - query will use connection.query()
1923- // - execute will use connection.execute()
1924- // If this query closure fails with some errors retry policy is used to perform retries
1925- // On success this query's result is returned
1919+ /// This method allows to easily run a request using load balancing, retry policy etc.
1920+ /// Requires some information about the request and a closure.
1921+ /// The closure is used to execute the request once on a chosen connection.
1922+ /// - query will use connection.query()
1923+ /// - execute will use connection.execute()
1924+ ///
1925+ /// If this closure fails with some errors, retry policy is used to perform retries.
1926+ /// On success, this request's result is returned.
19261927 // I tried to make this closures take a reference instead of an Arc but failed
19271928 // maybe once async closures get stabilized this can be fixed
1928- async fn run_query < ' a , QueryFut , ResT > (
1929+ async fn run_request < ' a , QueryFut , ResT > (
19291930 & ' a self ,
19301931 statement_info : RoutingInfo < ' a > ,
19311932 statement_config : & ' a StatementConfig ,
19321933 execution_profile : Arc < ExecutionProfileInner > ,
19331934 do_query : impl Fn ( Arc < Connection > , Consistency , & ExecutionProfileInner ) -> QueryFut ,
19341935 request_span : & ' a RequestSpan ,
1935- ) -> Result < RunQueryResult < ResT > , QueryError >
1936+ ) -> Result < RunRequestResult < ResT > , QueryError >
19361937 where
19371938 QueryFut : Future < Output = Result < ResT , QueryError > > ,
1938- ResT : AllowedRunQueryResTType ,
1939+ ResT : AllowedRunRequestResTType ,
19391940 {
19401941 let history_listener_and_id: Option < ( & ' a dyn HistoryListener , history:: QueryId ) > =
19411942 statement_config
@@ -2091,10 +2092,10 @@ where
20912092 do_query : impl Fn ( Arc < Connection > , Consistency , & ExecutionProfileInner ) -> QueryFut ,
20922093 execution_profile : & ExecutionProfileInner ,
20932094 mut context : ExecuteQueryContext < ' a > ,
2094- ) -> Option < Result < RunQueryResult < ResT > , QueryError > >
2095+ ) -> Option < Result < RunRequestResult < ResT > , QueryError > >
20952096 where
20962097 QueryFut : Future < Output = Result < ResT , QueryError > > ,
2097- ResT : AllowedRunQueryResTType ,
2098+ ResT : AllowedRunRequestResTType ,
20982099 {
20992100 let mut last_error: Option < QueryError > = None ;
21002101 let mut current_consistency: Consistency = context
@@ -2146,7 +2147,7 @@ where
21462147 elapsed,
21472148 node,
21482149 ) ;
2149- return Some ( Ok ( RunQueryResult :: Completed ( response) ) ) ;
2150+ return Some ( Ok ( RunRequestResult :: Completed ( response) ) ) ;
21502151 }
21512152 Err ( e) => {
21522153 trace ! (
@@ -2195,7 +2196,7 @@ where
21952196 RetryDecision :: DontRetry => break ' nodes_in_plan,
21962197
21972198 RetryDecision :: IgnoreWriteError => {
2198- return Some ( Ok ( RunQueryResult :: IgnoredWriteError ) )
2199+ return Some ( Ok ( RunRequestResult :: IgnoredWriteError ) )
21992200 }
22002201 } ;
22012202 }
@@ -2243,20 +2244,20 @@ where
22432244 }
22442245}
22452246
2246- // run_query , execute_query, etc have a template type called ResT.
2247+ // run_request , execute_query, etc have a template type called ResT.
22472248// There was a bug where ResT was set to QueryResponse, which could
22482249// be an error response. This was not caught by retry policy which
22492250// assumed all errors would come from analyzing Result<ResT, QueryError>.
22502251// This trait is a guard to make sure that this mistake doesn't
22512252// happen again.
2252- // When using run_query make sure that the ResT type is NOT able
2253+ // When using run_request make sure that the ResT type is NOT able
22532254// to contain any errors.
22542255// See https://github.com/scylladb/scylla-rust-driver/issues/501
2255- pub ( crate ) trait AllowedRunQueryResTType { }
2256+ pub ( crate ) trait AllowedRunRequestResTType { }
22562257
2257- impl AllowedRunQueryResTType for Uuid { }
2258- impl AllowedRunQueryResTType for QueryResult { }
2259- impl AllowedRunQueryResTType for NonErrorQueryResponse { }
2258+ impl AllowedRunRequestResTType for Uuid { }
2259+ impl AllowedRunRequestResTType for QueryResult { }
2260+ impl AllowedRunRequestResTType for NonErrorQueryResponse { }
22602261
22612262struct ExecuteQueryContext < ' a > {
22622263 is_idempotent : bool ,
0 commit comments