Skip to content

Commit 2376852

Browse files
committed
cluster: create constants for default config values
1 parent aeeda6a commit 2376852

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scylla-rust-wrapper/src/cluster.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ use std::time::Duration;
2626

2727
include!(concat!(env!("OUT_DIR"), "/cppdriver_compression_types.rs"));
2828

29+
// According to `cassandra.h` the default CPP driver's
30+
// - consistency for statements is LOCAL_ONE,
31+
// - request client timeout is 12000 millis.
32+
const DEFAULT_CONSISTENCY: Consistency = Consistency::LocalOne;
33+
const DEFAULT_REQUEST_TIMEOUT_MILLIS: u64 = 12000;
34+
2935
#[derive(Clone, Debug)]
3036
pub(crate) struct LoadBalancingConfig {
3137
pub(crate) token_awareness_enabled: bool,
@@ -115,12 +121,9 @@ pub fn build_session_builder(
115121

116122
#[no_mangle]
117123
pub unsafe extern "C" fn cass_cluster_new() -> *mut CassCluster {
118-
// According to `cassandra.h` the default CPP driver's
119-
// - consistency for statements is LOCAL_ONE,
120-
// - request client timeout is 12000 millis.
121124
let default_execution_profile_builder = ExecutionProfileBuilder::default()
122-
.consistency(Consistency::LocalOne)
123-
.request_timeout(Some(Duration::from_millis(12000)));
125+
.consistency(DEFAULT_CONSISTENCY)
126+
.request_timeout(Some(Duration::from_millis(DEFAULT_REQUEST_TIMEOUT_MILLIS)));
124127

125128
Box::into_raw(Box::new(CassCluster {
126129
session_builder: SessionBuilder::new(),

0 commit comments

Comments
 (0)