Skip to content

Commit 0ef1434

Browse files
committed
Nice
1 parent 091fdfe commit 0ef1434

File tree

6 files changed

+37
-44
lines changed

6 files changed

+37
-44
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ impl Connector for Postgres {
4040
/// can be polled but not updated directly.
4141
fn fetch_metrics(_configuration: &Self::Configuration, state: &Self::State) -> Result<()> {
4242
match &state.pool {
43-
state::Pool::Static { pool, .. } => state.query_metrics.update_pool_metrics(&pool),
44-
state::Pool::Dynamic(_) => {}
43+
state::Pool::Static { pool, .. } => state.query_metrics.update_pool_metrics(pool),
44+
state::Pool::Dynamic(()) => {}
4545
};
4646
Ok(())
4747
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ async fn execute_mutation(
9999
state: &state::State,
100100
plan: sql::execution_plan::ExecutionPlan<sql::execution_plan::Mutations>,
101101
) -> Result<JsonResponse<models::MutationResponse>, query_engine_execution::error::Error> {
102-
let (pool, database_info) = match &state.pool {
103-
state::Pool::Static {
104-
pool,
105-
database_info,
106-
} => (pool, database_info),
107-
_ => todo!("Dynamic connect for execute_mutation"),
102+
let state::Pool::Static {
103+
pool,
104+
database_info,
105+
} = &state.pool
106+
else {
107+
todo!("Dynamic connect for execute_mutation");
108108
};
109109

110-
query_engine_execution::mutation::execute(&pool, &database_info, &state.query_metrics, plan)
110+
query_engine_execution::mutation::execute(pool, database_info, &state.query_metrics, plan)
111111
.await
112112
.map(JsonResponse::Serialized)
113113
}

crates/connectors/ndc-postgres/src/mutation/explain.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
use std::collections::BTreeMap;
77

8-
use query_engine_execution::database_info;
98
use tracing::{info_span, Instrument};
109

1110
use ndc_postgres_configuration as configuration;
@@ -44,17 +43,17 @@ pub async fn explain(
4443

4544
// Execute an explain query.
4645
let results = async {
47-
let (pool, database_info) = match &state.pool {
48-
state::Pool::Static {
49-
pool,
50-
database_info,
51-
} => (pool, database_info),
52-
_ => todo!("Dynamic connect for explain_mutation"),
46+
let state::Pool::Static {
47+
pool,
48+
database_info,
49+
} = &state.pool
50+
else {
51+
todo!("Dynamic connect for explain_mutation");
5352
};
5453

5554
query_engine_execution::mutation::explain(
56-
&pool,
57-
&database_info,
55+
pool,
56+
database_info,
5857
&state.query_metrics,
5958
plan,
6059
)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ async fn execute_query(
8080
state: &state::State,
8181
plan: sql::execution_plan::ExecutionPlan<sql::execution_plan::Query>,
8282
) -> Result<JsonResponse<models::QueryResponse>, query_engine_execution::error::Error> {
83-
let (pool, database_info) = match &state.pool {
84-
state::Pool::Static {
85-
pool,
86-
database_info,
87-
} => (pool, database_info),
88-
_ => todo!("Dynamic connect for execute_query"),
83+
let state::Pool::Static {
84+
pool,
85+
database_info,
86+
} = &state.pool
87+
else {
88+
todo!("Dynamic connect for execute_query");
8989
};
9090

91-
query_engine_execution::query::execute(&pool, &database_info, &state.query_metrics, plan)
91+
query_engine_execution::query::execute(pool, database_info, &state.query_metrics, plan)
9292
.await
9393
.map(JsonResponse::Serialized)
9494
}

crates/connectors/ndc-postgres/src/query/explain.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
use std::collections::BTreeMap;
77

8-
use query_engine_execution::database_info;
98
use tracing::{info_span, Instrument};
109

1110
use ndc_postgres_configuration as configuration;
@@ -43,24 +42,19 @@ pub async fn explain(
4342

4443
// Execute an explain query.
4544
let (query, plan) = async {
46-
let (pool, database_info) = match &state.pool {
47-
state::Pool::Static {
48-
pool,
49-
database_info,
50-
} => (pool, database_info),
51-
_ => todo!("Dynamic connect for explain"),
45+
let state::Pool::Static {
46+
pool,
47+
database_info,
48+
} = &state.pool
49+
else {
50+
todo!("Dynamic connect for explain");
5251
};
53-
query_engine_execution::query::explain(
54-
&pool,
55-
&database_info,
56-
&state.query_metrics,
57-
plan,
58-
)
59-
.await
60-
.map_err(|err| {
61-
record::execution_error(&err, &state.query_metrics);
62-
convert::execution_error_to_response(err)
63-
})
52+
query_engine_execution::query::explain(pool, database_info, &state.query_metrics, plan)
53+
.await
54+
.map_err(|err| {
55+
record::execution_error(&err, &state.query_metrics);
56+
convert::execution_error_to_response(err)
57+
})
6458
}
6559
.instrument(info_span!("Explain query"))
6660
.await?;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub async fn create_state(
100100

101101
// update pool metrics if static pool is available
102102
if let Pool::Static { ref pool, .. } = pool {
103-
query_metrics.set_pool_options_metrics(&pool.options());
103+
query_metrics.set_pool_options_metrics(pool.options());
104104
}
105105

106106
configuration_metrics.set_configuration_version(version_tag);

0 commit comments

Comments
 (0)