Skip to content

cluster: schema agreement interval (extension) and timeout #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/cassandra.h
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,20 @@ CASS_EXPORT void
cass_cluster_set_max_schema_wait_time(CassCluster* cluster,
unsigned wait_time_ms);

/**
* Set the delay for schema agreement check after a schema change.
* How often driver should ask if schema is in agreement.
*
* <b>Default:</b> 200 milliseconds
*
* @public @memberof CassCluster
*
* @param[in] cluster
* @param[in] interval_ms Interval in milliseconds
*/
CASS_EXPORT void
cass_cluster_set_schema_agreement_interval(CassCluster* cluster,
unsigned interval_ms);

/**
* Sets the maximum time to wait for tracing data to become available.
Expand Down
29 changes: 29 additions & 0 deletions scylla-rust-wrapper/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const DEFAULT_CONSISTENCY: Consistency = Consistency::LocalOne;
const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_millis(12000);
// - fetching schema metadata is true
const DEFAULT_DO_FETCH_SCHEMA_METADATA: bool = true;
// - schema agreement timeout is 10000 millis,
const DEFAULT_MAX_SCHEMA_WAIT_TIME: Duration = Duration::from_millis(10000);
// - schema agreement interval is 200 millis.
// This default is taken from rust-driver, since this option is an extension to cpp-rust-driver.
const DEFAULT_SCHEMA_AGREEMENT_INTERVAL: Duration = Duration::from_millis(200);
// - setting TCP_NODELAY is true
const DEFAULT_SET_TCP_NO_DELAY: bool = true;
// - connect timeout is 5000 millis
Expand Down Expand Up @@ -179,6 +184,8 @@ pub unsafe extern "C" fn cass_cluster_new() -> *mut CassCluster {
SessionBuilder::new()
.custom_identity(custom_identity)
.fetch_schema_metadata(DEFAULT_DO_FETCH_SCHEMA_METADATA)
.schema_agreement_timeout(DEFAULT_MAX_SCHEMA_WAIT_TIME)
.schema_agreement_interval(DEFAULT_SCHEMA_AGREEMENT_INTERVAL)
.tcp_nodelay(DEFAULT_SET_TCP_NO_DELAY)
.connection_timeout(DEFAULT_CONNECT_TIMEOUT)
.keepalive_interval(DEFAULT_KEEPALIVE_INTERVAL)
Expand Down Expand Up @@ -408,6 +415,28 @@ pub unsafe extern "C" fn cass_cluster_set_request_timeout(
})
}

#[no_mangle]
pub unsafe extern "C" fn cass_cluster_set_max_schema_wait_time(
cluster_raw: *mut CassCluster,
wait_time_ms: c_uint,
) {
let cluster = ptr_to_ref_mut(cluster_raw);

cluster.session_builder.config.schema_agreement_timeout =
Duration::from_millis(wait_time_ms.into());
}

#[no_mangle]
pub unsafe extern "C" fn cass_cluster_set_schema_agreement_interval(
cluster_raw: *mut CassCluster,
interval_ms: c_uint,
) {
let cluster = ptr_to_ref_mut(cluster_raw);

cluster.session_builder.config.schema_agreement_interval =
Duration::from_millis(interval_ms.into());
}

#[no_mangle]
pub unsafe extern "C" fn cass_cluster_set_port(
cluster_raw: *mut CassCluster,
Expand Down