From 83e50cfba4c609d62e4aaf10f571d68f5aa0aee8 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" <carol.nichols@integer32.com> Date: Thu, 17 Jun 2021 16:53:32 -0400 Subject: [PATCH] refactor: Rename field to not contain the type --- data_types/src/database_rules.rs | 4 ++-- .../influxdata/iox/management/v1/database_rules.proto | 2 +- generated_types/src/database_rules.rs | 8 +++----- server/src/lib.rs | 4 ++-- server/src/write_buffer.rs | 2 +- tests/end_to_end_cases/management_api.rs | 2 +- tests/end_to_end_cases/write_buffer.rs | 4 ++-- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/data_types/src/database_rules.rs b/data_types/src/database_rules.rs index 3b18984258..35b266fa45 100644 --- a/data_types/src/database_rules.rs +++ b/data_types/src/database_rules.rs @@ -55,7 +55,7 @@ pub struct DatabaseRules { pub worker_cleanup_avg_sleep: Duration, /// An optional connection string to a write buffer. - pub write_buffer_connection_string: Option<String>, + pub write_buffer_connection: Option<String>, } #[derive(Debug, Eq, PartialEq, Clone)] @@ -86,7 +86,7 @@ impl DatabaseRules { lifecycle_rules: Default::default(), routing_rules: None, worker_cleanup_avg_sleep: Duration::from_secs(500), - write_buffer_connection_string: None, + write_buffer_connection: None, } } diff --git a/generated_types/protos/influxdata/iox/management/v1/database_rules.proto b/generated_types/protos/influxdata/iox/management/v1/database_rules.proto index 0c490d9024..d744340061 100644 --- a/generated_types/protos/influxdata/iox/management/v1/database_rules.proto +++ b/generated_types/protos/influxdata/iox/management/v1/database_rules.proto @@ -106,7 +106,7 @@ message DatabaseRules { google.protobuf.Duration worker_cleanup_avg_sleep = 10; // Optionally, the address of the write buffer - string write_buffer_connection_string = 11; + string write_buffer_connection = 11; } message RoutingConfig { diff --git a/generated_types/src/database_rules.rs b/generated_types/src/database_rules.rs index fc0a067409..907739c0be 100644 --- a/generated_types/src/database_rules.rs +++ b/generated_types/src/database_rules.rs @@ -21,9 +21,7 @@ impl From<DatabaseRules> for management::DatabaseRules { lifecycle_rules: Some(rules.lifecycle_rules.into()), routing_rules: rules.routing_rules.map(Into::into), worker_cleanup_avg_sleep: Some(rules.worker_cleanup_avg_sleep.into()), - write_buffer_connection_string: rules - .write_buffer_connection_string - .unwrap_or_default(), + write_buffer_connection: rules.write_buffer_connection.unwrap_or_default(), } } } @@ -54,7 +52,7 @@ impl TryFrom<management::DatabaseRules> for DatabaseRules { None => Duration::from_secs(500), }; - let write_buffer_connection_string = proto.write_buffer_connection_string.optional(); + let write_buffer_connection = proto.write_buffer_connection.optional(); Ok(Self { name, @@ -62,7 +60,7 @@ impl TryFrom<management::DatabaseRules> for DatabaseRules { lifecycle_rules, routing_rules, worker_cleanup_avg_sleep, - write_buffer_connection_string, + write_buffer_connection, }) } } diff --git a/server/src/lib.rs b/server/src/lib.rs index 8a48b03f46..27e625b7de 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -1220,7 +1220,7 @@ mod tests { }, routing_rules: None, worker_cleanup_avg_sleep: Duration::from_secs(2), - write_buffer_connection_string: None, + write_buffer_connection: None, }; // Create a database @@ -1312,7 +1312,7 @@ mod tests { lifecycle_rules: Default::default(), routing_rules: None, worker_cleanup_avg_sleep: Duration::from_secs(2), - write_buffer_connection_string: None, + write_buffer_connection: None, }; // Create a database diff --git a/server/src/write_buffer.rs b/server/src/write_buffer.rs index 1103147ed4..93af333208 100644 --- a/server/src/write_buffer.rs +++ b/server/src/write_buffer.rs @@ -17,7 +17,7 @@ pub fn new(rules: &DatabaseRules) -> Result<Option<Arc<dyn WriteBuffer>>, WriteB // trait, so always use `KafkaBuffer` when there is a write buffer connection string // specified. If/when there are other kinds of write buffers, additional configuration will // be needed to determine what kind of write buffer to use here. - match rules.write_buffer_connection_string.as_ref() { + match rules.write_buffer_connection.as_ref() { Some(conn) => { let kafka_buffer = KafkaBuffer::new(conn, name)?; diff --git a/tests/end_to_end_cases/management_api.rs b/tests/end_to_end_cases/management_api.rs index 2bb220f255..3b0bd70120 100644 --- a/tests/end_to_end_cases/management_api.rs +++ b/tests/end_to_end_cases/management_api.rs @@ -225,7 +225,7 @@ async fn test_create_get_update_database() { seconds: 2, nanos: 0, }), - write_buffer_connection_string: "".into(), + write_buffer_connection: "".into(), }; client diff --git a/tests/end_to_end_cases/write_buffer.rs b/tests/end_to_end_cases/write_buffer.rs index cabfd4bfd3..1ec54fec41 100644 --- a/tests/end_to_end_cases/write_buffer.rs +++ b/tests/end_to_end_cases/write_buffer.rs @@ -60,9 +60,9 @@ async fn writes_go_to_kafka() { // set up a database with a write buffer pointing at kafka let server = ServerFixture::create_shared().await; let db_name = rand_name(); - let write_buffer_connection_string = kafka_connection.to_string(); + let write_buffer_connection = kafka_connection.to_string(); create_readable_database_plus(&db_name, server.grpc_channel(), |mut rules| { - rules.write_buffer_connection_string = write_buffer_connection_string; + rules.write_buffer_connection = write_buffer_connection; rules }) .await;