Skip to content

Commit 168020e

Browse files
committed
use a constant for the argument names, and change them to camelCase for JSON consistency
1 parent 753bcb1 commit 168020e

File tree

1 file changed

+9
-6
lines changed
  • crates/connectors/ndc-postgres/src

1 file changed

+9
-6
lines changed

crates/connectors/ndc-postgres/src/state.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ use ndc_postgres_configuration::PoolSettings;
2323
use query_engine_execution::database_info::{self, DatabaseInfo, DatabaseVersion};
2424
use query_engine_execution::metrics;
2525

26+
const CONNECTION_NAME_ARGUMENT: &str = "connectionName";
27+
const CONNECTION_STRING_ARGUMENT: &str = "connectionString";
28+
2629
/// State for our connector.
2730
#[derive(Debug)]
2831
pub struct State {
@@ -95,8 +98,8 @@ pub enum Pool {
9598
},
9699
Named {
97100
fallback_pool: Option<Arc<PoolInstance>>,
98-
pools: Arc<RwLock<BTreeMap<String, Arc<PoolInstance>>>>,
99-
connection_uris: BTreeMap<String, Redacted<DatabaseConnectionString>>,
101+
pools: Arc<RwLock<BTreeMap<DatabaseConnectionName, Arc<PoolInstance>>>>,
102+
connection_uris: BTreeMap<DatabaseConnectionName, Redacted<DatabaseConnectionString>>,
100103
ssl: Redacted<SslInfo>,
101104
pool_settings: PoolSettings,
102105
next_pool_index: AtomicUsize,
@@ -213,7 +216,7 @@ impl Pool {
213216
// Extract the connection name from the request arguments
214217
if let Some(connection_name) = request_arguments
215218
.as_ref()
216-
.and_then(|request_arguments| request_arguments.get("connection_name"))
219+
.and_then(|request_arguments| request_arguments.get(CONNECTION_NAME_ARGUMENT))
217220
.and_then(|connection_name| connection_name.as_str())
218221
{
219222
{
@@ -260,7 +263,7 @@ impl Pool {
260263
Ok(fallback_pool.clone())
261264
} else {
262265
Err(PoolAquisitionError::MissingRequiredRequestArgument(
263-
"connection_name".to_string(),
266+
CONNECTION_NAME_ARGUMENT.to_string(),
264267
))
265268
}
266269
}
@@ -274,7 +277,7 @@ impl Pool {
274277
// Extract the connection string from the request arguments
275278
if let Some(connection_string) = request_arguments
276279
.as_ref()
277-
.and_then(|request_arguments| request_arguments.get("connection_string"))
280+
.and_then(|request_arguments| request_arguments.get(CONNECTION_STRING_ARGUMENT))
278281
.and_then(|connection_string| connection_string.as_str())
279282
{
280283
// Create a redacted version of the connection string for use as a key
@@ -319,7 +322,7 @@ impl Pool {
319322
Ok(fallback_pool.clone())
320323
} else {
321324
Err(PoolAquisitionError::MissingRequiredRequestArgument(
322-
"connection_string".to_string(),
325+
CONNECTION_STRING_ARGUMENT.to_string(),
323326
))
324327
}
325328
}

0 commit comments

Comments
 (0)