Add speculative_execution method to session builder
use super::errors::NewSessionError;
use super::load_balancing::LoadBalancingPolicy;
use super::session::{Session, SessionConfig};
+use super::speculative_execution::SpeculativeExecutionPolicy;
use super::Compression;
use crate::transport::retry_policy::RetryPolicy;
use std::net::SocketAddr;
@@ -251,6 +252,39 @@ impl SessionBuilder {
self
}
+ /// Set the speculative execution policy
+ /// The default is None
+ /// # Example
+ /// ```
+ /// # extern crate scylla;
+ /// # use scylla::Session;
+ /// # use std::error::Error;
+ /// # async fn check_only_compiles() -> Result<(), Box<dyn Error>> {
+ /// use std::{sync::Arc, time::Duration};
+ /// use scylla::{
+ /// Session,
+ /// SessionBuilder,
+ /// transport::speculative_execution::SimpleSpeculativeExecutionPolicy
+ /// };
+ ///
+ /// let policy = SimpleSpeculativeExecutionPolicy {
+ /// max_retry_count: 3,
+ /// retry_interval: Duration::from_millis(100),
+ /// };
+ ///
+ /// let session: Session = SessionBuilder::new()
+ /// .known_node("127.0.0.1:9042")
+ /// .speculative_execution(Arc::new(policy))
+ /// .build()
+ /// .await?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub fn speculative_execution(mut self, policy: Arc<dyn SpeculativeExecutionPolicy>) -> Self {
+ self.config.speculative_execution_policy = Some(policy);
+ self
+ }
+
/// Sets the [`RetryPolicy`] to use by default on queries
/// The default is [DefaultRetryPolicy](crate::transport::retry_policy::DefaultRetryPolicy)
/// It is possible to implement a custom retry policy by implementing the trait [`RetryPolicy`]
