Skip to content

Commit ef80cd9

Browse files
committed
session: rename execute_query -> run_request_speculative_fiber
Again, query would suggest that we want to execute a CQL QUERY request. New name also clearly tells the user that provided closure can be potentially executed multiple (based on plan and retry session). Documented the function. Renamed ExecuteQueryContext -> ExecuteRequestContext
1 parent 124ada0 commit ef80cd9

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

scylla/src/transport/session.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ where
19851985
iter: std::sync::Mutex::new(query_plan),
19861986
};
19871987

1988-
let execute_query_generator = |is_speculative: bool| {
1988+
let request_runner_generator = |is_speculative: bool| {
19891989
let history_data: Option<HistoryData> = history_listener_and_id
19901990
.as_ref()
19911991
.map(|(history_listener, query_id)| {
@@ -2006,11 +2006,11 @@ where
20062006
request_span.inc_speculative_executions();
20072007
}
20082008

2009-
self.execute_query(
2009+
self.run_request_speculative_fiber(
20102010
&shared_query_plan,
20112011
&do_query,
20122012
&execution_profile,
2013-
ExecuteQueryContext {
2013+
ExecuteRequestContext {
20142014
is_idempotent: statement_config.is_idempotent,
20152015
consistency_set_on_statement: statement_config.consistency,
20162016
retry_session: retry_policy.new_session(),
@@ -2028,7 +2028,7 @@ where
20282028
speculative_execution::execute(
20292029
speculative.as_ref(),
20302030
&context,
2031-
execute_query_generator,
2031+
request_runner_generator,
20322032
)
20332033
.await
20342034
}
@@ -2041,11 +2041,11 @@ where
20412041
query_id: *query_id,
20422042
speculative_id: None,
20432043
});
2044-
self.execute_query(
2044+
self.run_request_speculative_fiber(
20452045
query_plan,
20462046
&do_query,
20472047
&execution_profile,
2048-
ExecuteQueryContext {
2048+
ExecuteRequestContext {
20492049
is_idempotent: statement_config.is_idempotent,
20502050
consistency_set_on_statement: statement_config.consistency,
20512051
retry_session: retry_policy.new_session(),
@@ -2086,12 +2086,17 @@ where
20862086
result
20872087
}
20882088

2089-
async fn execute_query<'a, QueryFut, ResT>(
2089+
/// Executes the closure `do_query`, provided the load balancing plan and some information
2090+
/// about the request, including retry session.
2091+
/// If request fails, retry session is used to perform retries.
2092+
///
2093+
/// Returns None, if provided plan is empty.
2094+
async fn run_request_speculative_fiber<'a, QueryFut, ResT>(
20902095
&'a self,
20912096
query_plan: impl Iterator<Item = (NodeRef<'a>, Shard)>,
20922097
do_query: impl Fn(Arc<Connection>, Consistency, &ExecutionProfileInner) -> QueryFut,
20932098
execution_profile: &ExecutionProfileInner,
2094-
mut context: ExecuteQueryContext<'a>,
2099+
mut context: ExecuteRequestContext<'a>,
20952100
) -> Option<Result<RunRequestResult<ResT>, QueryError>>
20962101
where
20972102
QueryFut: Future<Output = Result<ResT, QueryError>>,
@@ -2244,7 +2249,7 @@ where
22442249
}
22452250
}
22462251

2247-
// run_request, execute_query, etc have a template type called ResT.
2252+
// run_request, run_request_speculative_fiber, etc have a template type called ResT.
22482253
// There was a bug where ResT was set to QueryResponse, which could
22492254
// be an error response. This was not caught by retry policy which
22502255
// assumed all errors would come from analyzing Result<ResT, QueryError>.
@@ -2259,7 +2264,7 @@ impl AllowedRunRequestResTType for Uuid {}
22592264
impl AllowedRunRequestResTType for QueryResult {}
22602265
impl AllowedRunRequestResTType for NonErrorQueryResponse {}
22612266

2262-
struct ExecuteQueryContext<'a> {
2267+
struct ExecuteRequestContext<'a> {
22632268
is_idempotent: bool,
22642269
consistency_set_on_statement: Option<Consistency>,
22652270
retry_session: Box<dyn RetrySession>,
@@ -2274,7 +2279,7 @@ struct HistoryData<'a> {
22742279
speculative_id: Option<history::SpeculativeId>,
22752280
}
22762281

2277-
impl ExecuteQueryContext<'_> {
2282+
impl ExecuteRequestContext<'_> {
22782283
fn log_attempt_start(&self, node_addr: SocketAddr) -> Option<history::AttemptId> {
22792284
self.history_data.as_ref().map(|hd| {
22802285
hd.listener

0 commit comments

Comments
 (0)