Skip to content

Commit

Permalink
Move v2_compat behind a Cargo feature.
Browse files Browse the repository at this point in the history
This allows us to remove `gdc_rust_types` from the dependency tree if we
don't need it.
  • Loading branch information
SamirTalwar committed Feb 26, 2024
1 parent b81fc0b commit 3672be0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions rust-connector-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ path = "src/lib.rs"
name = "ndc_hub_example"
path = "bin/main.rs"

[features]
v2_compat = ["dep:gdc_rust_types", "dep:indexmap"]

[dependencies]
gdc_rust_types = { git = "https://github.com/hasura/gdc_rust_types.git", rev = "3273434" }
gdc_rust_types = { git = "https://github.com/hasura/gdc_rust_types.git", rev = "3273434", optional = true } # used for v2_compat
ndc-client = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.18" }
ndc-test = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.18" }

Expand All @@ -22,7 +25,7 @@ axum-extra = "^0.8.0"
bytes = "1.5.0"
clap = { version = "^4.4.7", features = ["derive", "env"] }
http = "^0.2"
indexmap = "2"
indexmap = { version = "2", optional = true } # used for v2_compat
mime = "0.3.17"
opentelemetry = { version = "^0.20", default-features = false, features = ["rt-tokio", "trace"] }
opentelemetry-http = "0.9.0"
Expand Down
7 changes: 4 additions & 3 deletions rust-connector-sdk/src/default_main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "v2_compat")]
mod v2_compat;

use std::error::Error;
Expand Down Expand Up @@ -180,11 +181,10 @@ where
serve_command.service_token_secret.clone(),
);

let router = if serve_command.enable_v2_compatibility {
#[cfg(feature = "v2_compat")]
let router = {
let v2_router = create_v2_router(server_state, serve_command.service_token_secret.clone());
Router::new().merge(router).nest("/v2", v2_router)
} else {
router
};

let port = serve_command.port;
Expand Down Expand Up @@ -326,6 +326,7 @@ where
))
}

#[cfg(feature = "v2_compat")]
pub fn create_v2_router<C: Connector + 'static>(
state: ServerState<C>,
service_token_secret: Option<String>,
Expand Down

0 comments on commit 3672be0

Please sign in to comment.