session: Created mod for session-global defaults
This prevents the scenario that default values for session config are
defined independently in multiple places, possibly leading to
inconsistency. At the moments, the values that are to be part of
ExecutionProfile are defined there.
@@ -66,6 +66,42 @@ use crate::authentication::AuthenticatorProvider;
#[cfg(feature = "ssl")]
use openssl::ssl::SslContext;
+/// Stores default (somehow recommended) configuration options for Session.
+pub mod defaults {
+ use scylla_cql::frame::types::SerialConsistency;
+ use scylla_cql::Consistency;
+ use std::sync::Arc;
+ use std::time::Duration;
+
+ use crate::load_balancing::{LoadBalancingPolicy, RoundRobinPolicy, TokenAwarePolicy};
+ use crate::retry_policy::{DefaultRetryPolicy, RetryPolicy};
+ use crate::speculative_execution::SpeculativeExecutionPolicy;
+
+ pub fn consistency() -> Consistency {
+ Consistency::LocalQuorum
+ }
+
+ pub fn serial_consistency() -> Option<SerialConsistency> {
+ None
+ }
+
+ pub fn request_timeout() -> Option<Duration> {
+ Some(Duration::from_secs(30))
+ }
+
+ pub fn load_balancing_policy() -> Arc<dyn LoadBalancingPolicy> {
+ Arc::new(TokenAwarePolicy::new(Box::new(RoundRobinPolicy::new())))
+ }
+
+ pub fn retry_policy() -> Box<dyn RetryPolicy> {
+ Box::new(DefaultRetryPolicy::new())
+ }
+
+ pub fn speculative_execution_policy() -> Option<Arc<dyn SpeculativeExecutionPolicy>> {
+ None
+ }
+}
+
#[derive(Debug, Copy, Clone)]
pub enum TranslationError {
NoRuleForAddress,
