Skip to content

Commit 8238086

Browse files
authored
Merge pull request #198 from muzarski/max-schema-wait-time
cluster: schema agreement interval (extension) and timeout
2 parents f5760c1 + 7cb9de3 commit 8238086

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

include/cassandra.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,20 @@ CASS_EXPORT void
20682068
cass_cluster_set_max_schema_wait_time(CassCluster* cluster,
20692069
unsigned wait_time_ms);
20702070

2071+
/**
2072+
* Set the delay for schema agreement check after a schema change.
2073+
* How often driver should ask if schema is in agreement.
2074+
*
2075+
* <b>Default:</b> 200 milliseconds
2076+
*
2077+
* @public @memberof CassCluster
2078+
*
2079+
* @param[in] cluster
2080+
* @param[in] interval_ms Interval in milliseconds
2081+
*/
2082+
CASS_EXPORT void
2083+
cass_cluster_set_schema_agreement_interval(CassCluster* cluster,
2084+
unsigned interval_ms);
20712085

20722086
/**
20732087
* Sets the maximum time to wait for tracing data to become available.

scylla-rust-wrapper/src/cluster.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const DEFAULT_CONSISTENCY: Consistency = Consistency::LocalOne;
3535
const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_millis(12000);
3636
// - fetching schema metadata is true
3737
const DEFAULT_DO_FETCH_SCHEMA_METADATA: bool = true;
38+
// - schema agreement timeout is 10000 millis,
39+
const DEFAULT_MAX_SCHEMA_WAIT_TIME: Duration = Duration::from_millis(10000);
40+
// - schema agreement interval is 200 millis.
41+
// This default is taken from rust-driver, since this option is an extension to cpp-rust-driver.
42+
const DEFAULT_SCHEMA_AGREEMENT_INTERVAL: Duration = Duration::from_millis(200);
3843
// - setting TCP_NODELAY is true
3944
const DEFAULT_SET_TCP_NO_DELAY: bool = true;
4045
// - connect timeout is 5000 millis
@@ -179,6 +184,8 @@ pub unsafe extern "C" fn cass_cluster_new() -> *mut CassCluster {
179184
SessionBuilder::new()
180185
.custom_identity(custom_identity)
181186
.fetch_schema_metadata(DEFAULT_DO_FETCH_SCHEMA_METADATA)
187+
.schema_agreement_timeout(DEFAULT_MAX_SCHEMA_WAIT_TIME)
188+
.schema_agreement_interval(DEFAULT_SCHEMA_AGREEMENT_INTERVAL)
182189
.tcp_nodelay(DEFAULT_SET_TCP_NO_DELAY)
183190
.connection_timeout(DEFAULT_CONNECT_TIMEOUT)
184191
.keepalive_interval(DEFAULT_KEEPALIVE_INTERVAL)
@@ -408,6 +415,28 @@ pub unsafe extern "C" fn cass_cluster_set_request_timeout(
408415
})
409416
}
410417

418+
#[no_mangle]
419+
pub unsafe extern "C" fn cass_cluster_set_max_schema_wait_time(
420+
cluster_raw: *mut CassCluster,
421+
wait_time_ms: c_uint,
422+
) {
423+
let cluster = ptr_to_ref_mut(cluster_raw);
424+
425+
cluster.session_builder.config.schema_agreement_timeout =
426+
Duration::from_millis(wait_time_ms.into());
427+
}
428+
429+
#[no_mangle]
430+
pub unsafe extern "C" fn cass_cluster_set_schema_agreement_interval(
431+
cluster_raw: *mut CassCluster,
432+
interval_ms: c_uint,
433+
) {
434+
let cluster = ptr_to_ref_mut(cluster_raw);
435+
436+
cluster.session_builder.config.schema_agreement_interval =
437+
Duration::from_millis(interval_ms.into());
438+
}
439+
411440
#[no_mangle]
412441
pub unsafe extern "C" fn cass_cluster_set_port(
413442
cluster_raw: *mut CassCluster,

0 commit comments

Comments
 (0)