Skip to content

Commit

Permalink
Remove unused constructors and packages, add cargo machete job to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljharvey committed Dec 20, 2024
1 parent 8cd1861 commit 9f5da8a
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 358 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/cargo-machete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: find unused dependencies

on:
push:

jobs:
cargo-machete:
name: find unused dependencies with cargo machete
runs-on: ubuntu-latest
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
RUSTFLAGS: "-D warnings" # fail on warnings
steps:
- uses: actions/checkout@v4

- name: install tools
run: |
rustup show
cargo install cargo-machete
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs
save-if: false

- name: find unused dependencies
run: |
cargo machete --with-metadata
173 changes: 0 additions & 173 deletions architecture.md

This file was deleted.

1 change: 0 additions & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ndc-bigquery-configuration = { path = "../configuration" }
anyhow = { workspace = true }
clap = { workspace = true, features = ["derive", "env"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["full"] }
Expand Down
7 changes: 0 additions & 7 deletions crates/configuration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@ workspace = true
[dependencies]
ndc-models = { workspace = true }
query-engine-metadata = { path = "../query-engine/metadata" }
query-engine-sql = { path = "../query-engine/sql" }

anyhow = { workspace = true }
# We only use clap for the derive.
clap = { workspace = true, features = ["derive", "env"] }
prometheus = {workspace = true }
schemars = { workspace = true, features = ["smol_str", "preserve_order"] }
serde = { workspace = true }
serde_json = { workspace = true, features = ["raw_value"] }
smol_str = { workspace = true }
sqlx = { workspace = true, features = ["json", "postgres", "runtime-tokio-rustls"] }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
yup-oauth2 = { workspace = true }
gcp-bigquery-client = { workspace = true }

Expand Down
5 changes: 0 additions & 5 deletions crates/connectors/ndc-bigquery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ ndc-bigquery-configuration = { path = "../../configuration" }
ndc-sdk = { workspace = true }

async-trait = { workspace = true }
enum-iterator = { workspace = true }
gcp-bigquery-client = { workspace = true }
prometheus = { workspace = true }
schemars = { workspace = true, features = ["smol_str", "preserve_order"] }
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true, features = ["raw_value"] }
sqlx = { workspace = true, features = [ "json", "postgres", "runtime-tokio-rustls" ] }
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
thiserror = { workspace = true }
Expand Down
9 changes: 0 additions & 9 deletions crates/connectors/ndc-bigquery/src/error/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@ pub fn execution_error_to_response(error: query_engine_execution::error::Error)
QueryError::NotSupported(_) => {
connector::QueryError::new_unsupported_operation(&query_error.to_string()).into()
}
QueryError::DBError(_) => {
connector::QueryError::new_unprocessable_content(&query_error.to_string()).into()
}
QueryError::DBConstraintError(_) | QueryError::MutationConstraintFailed => {
connector::MutationError::new_constraint_not_met(&query_error.to_string()).into()
}
},
Error::DB(_) => {
ErrorResponse::new_internal_with_details(serde_json::Value::String(error.to_string()))
}
}
}

Expand Down
8 changes: 1 addition & 7 deletions crates/connectors/ndc-bigquery/src/error/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ pub fn execution_error(error: &query_engine_execution::error::Error, metrics: &m
tracing::error!("{}", error);
match error {
Error::Query(err) => match &err {
QueryError::VariableNotFound(_)
| QueryError::DBError(_)
| QueryError::MutationConstraintFailed
| QueryError::DBConstraintError(_) => {
QueryError::VariableNotFound(_) => {
metrics.error_metrics.record_invalid_request();
}
QueryError::NotSupported(_) => {
metrics.error_metrics.record_unsupported_feature();
}
},
Error::DB(_) => {
metrics.error_metrics.record_database_error();
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions crates/connectors/ndc-bigquery/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ pub async fn create_state(
/// State initialization error.
#[derive(Debug, Error)]
pub enum InitializationError {
#[error("unable to initialize connection pool: {0}")]
UnableToCreatePool(sqlx::Error),
#[error("error initializing metrics: {0}")]
MetricsError(prometheus::Error),
}
5 changes: 0 additions & 5 deletions crates/query-engine/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ license.workspace = true
workspace = true

[dependencies]
ndc-models = { workspace = true }

query-engine-sql = { path = "../sql" }

gcp-bigquery-client = { workspace = true }
prometheus = { workspace = true }
serde_json = { workspace = true }
sqlformat = { workspace = true }
sqlx = { workspace = true, features = [ "json", "postgres", "runtime-tokio-rustls", "uuid" ] }
thiserror = { workspace = true }
tracing = { workspace = true }
bytes = { workspace = true }
31 changes: 0 additions & 31 deletions crates/query-engine/execution/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
pub enum Error {
#[error("{0}")]
Query(QueryError),
#[error("{0}")]
DB(sqlx::Error),
}

/// Query planning error.
Expand All @@ -14,33 +12,4 @@ pub enum QueryError {
VariableNotFound(String),
#[error("{0} are not supported.")]
NotSupported(String),
#[error("{0}")]
DBError(sqlx::Error),
#[error("{0}")]
DBConstraintError(sqlx::Error),
#[error("Mutation constraint failed.")]
MutationConstraintFailed,
}

impl From<sqlx::Error> for Error {
fn from(err: sqlx::Error) -> Error {
match err
.as_database_error()
.and_then(|e| e.try_downcast_ref())
.map(|e: &sqlx::postgres::PgDatabaseError| e.code())
{
None => Error::DB(err),
Some(code) => {
// We want to map data and constraint exceptions to query errors
// https://www.postgresql.org/docs/current/errcodes-appendix.html
if code.starts_with("22") {
Error::Query(QueryError::DBError(err))
} else if code.starts_with("23") {
Error::Query(QueryError::DBConstraintError(err))
} else {
Error::DB(err)
}
}
}
}
}
Loading

0 comments on commit 9f5da8a

Please sign in to comment.