Skip to content
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

Configuration of replication strategy parsing fix. #83

Merged
merged 1 commit into from
Feb 21, 2022
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
2 changes: 1 addition & 1 deletion cdrs-tokio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cdrs-tokio"
version = "6.0.0"
version = "6.0.1"
authors = ["Alex Pikalov <alex.pikalov.khar@gmail.com>", "Kamil Rojewski <kamil.rojewski@gmail.com>"]
edition = "2018"
description = "Async Cassandra DB driver written in Rust"
Expand Down
10 changes: 7 additions & 3 deletions cdrs-tokio/src/cluster/cluster_metadata_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ fn build_keyspace(row: &Row) -> Result<(String, KeyspaceMetadata)> {
Ok((keyspace_name, KeyspaceMetadata::new(replication_strategy)))
}

fn build_replication_strategy(properties: Map<String, JsonValue>) -> Result<ReplicationStrategy> {
match properties.get("class") {
fn build_replication_strategy(
mut properties: Map<String, JsonValue>,
) -> Result<ReplicationStrategy> {
match properties.remove("class") {
Some(JsonValue::String(class)) => Ok(match class.as_str() {
"org.apache.cassandra.locator.SimpleStrategy" | "SimpleStrategy" => {
ReplicationStrategy::SimpleStrategy {
Expand Down Expand Up @@ -287,7 +289,9 @@ fn extract_replication_factor(value: Option<&JsonValue>) -> Result<usize> {
usize::from_str(replication_factor)
};

result.map_err(|error| format!("Error parsing replication factor: {}", error).into())
result.map_err(|error| {
format!("Failed to parse ('{}'): {}", replication_factor, error).into()
})
}
_ => Err("Missing replication factor!".into()),
}
Expand Down