Rename speculative execution policy struct members
@@ -7,8 +7,8 @@ use super::errors::QueryError;
#[derive(Debug, Clone)]
pub struct SpeculativeExecutionPolicy {
- pub attempts_count: usize,
- pub delay: Duration,
+ pub max_retry_count: usize,
+ pub retry_interval: Duration,
}
impl SpeculativeExecutionPolicy {
@@ -19,30 +19,30 @@ impl SpeculativeExecutionPolicy {
where
QueryFut: Future<Output = Option<Result<ResT, QueryError>>>,
{
- let mut available_attempts = self.attempts_count;
+ let mut retries_remaining = self.max_retry_count;
let mut async_tasks = FuturesUnordered::new();
async_tasks.push(query_runner_generator());
- let sleep = tokio::time::sleep(self.delay).fuse();
+ let sleep = tokio::time::sleep(self.retry_interval).fuse();
tokio::pin!(sleep);
loop {
futures::select! {
_ = &mut sleep => {
- if available_attempts > 0 {
+ if retries_remaining > 0 {
async_tasks.push(query_runner_generator());
- available_attempts -= 1;
+ retries_remaining -= 1;
// reset the timeout
- sleep.set(tokio::time::sleep(self.delay).fuse());
+ sleep.set(tokio::time::sleep(self.retry_interval).fuse());
}
}
res = async_tasks.select_next_some() => {
match res {
Some(r) => return r,
None => {
- if async_tasks.is_empty() && available_attempts == 0 {
+ if async_tasks.is_empty() && retries_remaining == 0 {
return Err(QueryError::ProtocolError(
"Empty query plan - driver bug!",
));
