Skip to content

Commit

Permalink
Use Option for datacenter to keep backwards compatibility
Browse files Browse the repository at this point in the history
Adding non-optional datacenter field to the config
made it impossible to load old reports.
  • Loading branch information
pkolaczk committed Jul 5, 2024
1 parent 872a7eb commit fe230a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ pub struct ConnectionConf {
pub ssl_key_file: Option<PathBuf>,

/// Datacenter name
#[clap(long("datacenter"), required = false, default_value = "")]
pub datacenter: String,
#[clap(long("datacenter"), required = false)]
pub datacenter: Option<String>,

/// Default CQL query consistency level
#[clap(long("consistency"), required = false, default_value = "LOCAL_QUORUM")]
Expand Down
3 changes: 1 addition & 2 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ fn ssl_context(conf: &&ConnectionConf) -> Result<Option<SslContext>, CassError>
/// Configures connection to Cassandra.
pub async fn connect(conf: &ConnectionConf) -> Result<Context, CassError> {
let mut policy_builder = DefaultPolicy::builder().token_aware(true);
let dc = &conf.datacenter;
if !dc.is_empty() {
if let Some(dc) = &conf.datacenter {
policy_builder = policy_builder
.prefer_datacenter(dc.to_owned())
.permit_dc_failover(true);
Expand Down
4 changes: 3 additions & 1 deletion src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,9 @@ impl<'a> Display for RunConfigCmp<'a> {
}

let lines: Vec<Box<dyn Display>> = vec![
self.line("Datacenter", "", |conf| conf.connection.datacenter.clone()),
self.line("Datacenter", "", |conf| {
conf.connection.datacenter.clone().unwrap_or_default()
}),
self.line("Consistency", "", |conf| {
conf.connection.consistency.scylla_consistency().to_string()
}),
Expand Down

0 comments on commit fe230a3

Please sign in to comment.