From 8cc66cb2ec2eead34923ef71836b36e295c79697 Mon Sep 17 00:00:00 2001 From: YassinEldeeb Date: Sun, 19 Nov 2023 06:30:17 +0200 Subject: [PATCH 1/8] cargo workspace yassin feedback --- .github/workflows/release.yaml | 1 - Cargo.lock | 22 +++++++++--------- Cargo.toml | 2 +- {crates => bin}/cloudflare_worker/Cargo.toml | 6 ++--- .../cloudflare_worker/package-lock.json | 0 .../cloudflare_worker/package.json | 0 {crates => bin}/cloudflare_worker/src/lib.rs | 4 ++-- .../cloudflare_worker/wrangler.toml | 0 {crates => bin}/conductor/Cargo.toml | 6 ++--- {crates => bin}/conductor/docker/Dockerfile | 0 {crates => bin}/conductor/docker/bake.hcl | 0 {crates => bin}/conductor/src/lib.rs | 0 {crates => bin}/conductor/src/main.rs | 0 {crates => libs}/.DS_Store | Bin {crates => libs}/benches/Cargo.toml | 2 +- {crates => libs}/benches/bench.rs | 0 {crates => libs}/benches/config.yaml | 0 {crates => libs}/common/Cargo.toml | 0 {crates => libs}/common/src/graphql.rs | 0 {crates => libs}/common/src/http.rs | 0 {crates => libs}/common/src/json.rs | 0 {crates => libs}/common/src/lib.rs | 0 {crates => libs}/config/Cargo.toml | 0 {crates => libs}/config/conductor.schema.json | 0 .../config/src/generate-json-schema.rs | 0 {crates => libs}/config/src/lib.rs | 14 +++++++---- {crates => libs}/config/src/plugins.rs | 0 {crates => libs}/config/src/serde_utils.rs | 0 {crates => libs}/engine/Cargo.toml | 2 +- .../engine/src/endpoint_runtime.rs | 0 {crates => libs}/engine/src/gateway.rs | 0 {crates => libs}/engine/src/lib.rs | 0 {crates => libs}/engine/src/plugins/core.rs | 0 .../engine/src/plugins/graphiql_plugin.rs | 0 .../engine/src/plugins/http_get_plugin.rs | 0 .../engine/src/plugins/match_content_type.rs | 0 {crates => libs}/engine/src/plugins/mod.rs | 0 .../src/plugins/persisted_documents/config.rs | 0 .../src/plugins/persisted_documents/mod.rs | 0 .../src/plugins/persisted_documents/plugin.rs | 0 .../protocols/apollo_manifest.rs | 0 .../protocols/document_id.rs | 0 .../protocols/get_handler.rs | 0 .../persisted_documents/protocols/mod.rs | 0 .../plugins/persisted_documents/store/fs.rs | 0 .../plugins/persisted_documents/store/mod.rs | 0 .../engine/src/plugins/plugin_manager.rs | 0 .../engine/src/request_execution_context.rs | 0 .../engine/src/source/graphql_source.rs | 6 ++--- {crates => libs}/engine/src/source/mod.rs | 0 {crates => libs}/engine/src/source/runtime.rs | 0 .../wasm_polyfills}/Cargo.toml | 3 +-- .../wasm_polyfills}/src/lib.rs | 0 test_config/config.yaml | 4 ++-- 54 files changed, 36 insertions(+), 36 deletions(-) rename {crates => bin}/cloudflare_worker/Cargo.toml (74%) rename {crates => bin}/cloudflare_worker/package-lock.json (100%) rename {crates => bin}/cloudflare_worker/package.json (100%) rename {crates => bin}/cloudflare_worker/src/lib.rs (96%) rename {crates => bin}/cloudflare_worker/wrangler.toml (100%) rename {crates => bin}/conductor/Cargo.toml (67%) rename {crates => bin}/conductor/docker/Dockerfile (100%) rename {crates => bin}/conductor/docker/bake.hcl (100%) rename {crates => bin}/conductor/src/lib.rs (100%) rename {crates => bin}/conductor/src/main.rs (100%) rename {crates => libs}/.DS_Store (100%) rename {crates => libs}/benches/Cargo.toml (89%) rename {crates => libs}/benches/bench.rs (100%) rename {crates => libs}/benches/config.yaml (100%) rename {crates => libs}/common/Cargo.toml (100%) rename {crates => libs}/common/src/graphql.rs (100%) rename {crates => libs}/common/src/http.rs (100%) rename {crates => libs}/common/src/json.rs (100%) rename {crates => libs}/common/src/lib.rs (100%) rename {crates => libs}/config/Cargo.toml (100%) rename {crates => libs}/config/conductor.schema.json (100%) rename {crates => libs}/config/src/generate-json-schema.rs (100%) rename {crates => libs}/config/src/lib.rs (91%) rename {crates => libs}/config/src/plugins.rs (100%) rename {crates => libs}/config/src/serde_utils.rs (100%) rename {crates => libs}/engine/Cargo.toml (89%) rename {crates => libs}/engine/src/endpoint_runtime.rs (100%) rename {crates => libs}/engine/src/gateway.rs (100%) rename {crates => libs}/engine/src/lib.rs (100%) rename {crates => libs}/engine/src/plugins/core.rs (100%) rename {crates => libs}/engine/src/plugins/graphiql_plugin.rs (100%) rename {crates => libs}/engine/src/plugins/http_get_plugin.rs (100%) rename {crates => libs}/engine/src/plugins/match_content_type.rs (100%) rename {crates => libs}/engine/src/plugins/mod.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/config.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/mod.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/plugin.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/protocols/apollo_manifest.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/protocols/document_id.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/protocols/get_handler.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/protocols/mod.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/store/fs.rs (100%) rename {crates => libs}/engine/src/plugins/persisted_documents/store/mod.rs (100%) rename {crates => libs}/engine/src/plugins/plugin_manager.rs (100%) rename {crates => libs}/engine/src/request_execution_context.rs (100%) rename {crates => libs}/engine/src/source/graphql_source.rs (93%) rename {crates => libs}/engine/src/source/mod.rs (100%) rename {crates => libs}/engine/src/source/runtime.rs (100%) rename {crates/async_runtime => libs/wasm_polyfills}/Cargo.toml (94%) rename {crates/async_runtime => libs/wasm_polyfills}/src/lib.rs (100%) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 47a736f2..c48e6e2b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -138,7 +138,6 @@ jobs: command: build target: ${{ matrix.platform.target }} args: "--locked --release" - strip: false - uses: actions/upload-artifact@v3 if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }} diff --git a/Cargo.lock b/Cargo.lock index a927564c..1ce08e99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -268,16 +268,6 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "async_runtime" -version = "0.0.0" -dependencies = [ - "reqwest", - "send_wrapper", - "tokio", - "wasm-bindgen-futures", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -569,7 +559,6 @@ name = "conductor_engine" version = "0.0.0" dependencies = [ "async-trait", - "async_runtime", "conductor_common", "conductor_config", "matchit 0.7.3", @@ -578,6 +567,7 @@ dependencies = [ "serde_json", "thiserror", "tracing", + "wasm_polyfills", ] [[package]] @@ -2429,6 +2419,16 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasm_polyfills" +version = "0.0.0" +dependencies = [ + "reqwest", + "send_wrapper", + "tokio", + "wasm-bindgen-futures", +] + [[package]] name = "web-sys" version = "0.3.63" diff --git a/Cargo.toml b/Cargo.toml index c7bf42fc..29eff127 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["crates/*"] +members = ["libs/*", "bin/*"] resolver = "2" [workspace.dependencies] diff --git a/crates/cloudflare_worker/Cargo.toml b/bin/cloudflare_worker/Cargo.toml similarity index 74% rename from crates/cloudflare_worker/Cargo.toml rename to bin/cloudflare_worker/Cargo.toml index 0cdc3c14..16dbd1c3 100644 --- a/crates/cloudflare_worker/Cargo.toml +++ b/bin/cloudflare_worker/Cargo.toml @@ -12,9 +12,9 @@ crate-type = ["cdylib"] [dependencies] worker = "0.0.18" -conductor_config = { path = "../config" } -conductor_engine = { path = "../engine" } -conductor_common = { path = "../common" } +conductor_config = { path = "../../libs/config" } +conductor_engine = { path = "../../libs/engine" } +conductor_common = { path = "../../libs/common" } tracing-web = "0.1.2" tracing-subscriber = { version = "0.3.18", features = ['time', 'json'] } time = { version = "0.3.30", features = ['wasm-bindgen'] } diff --git a/crates/cloudflare_worker/package-lock.json b/bin/cloudflare_worker/package-lock.json similarity index 100% rename from crates/cloudflare_worker/package-lock.json rename to bin/cloudflare_worker/package-lock.json diff --git a/crates/cloudflare_worker/package.json b/bin/cloudflare_worker/package.json similarity index 100% rename from crates/cloudflare_worker/package.json rename to bin/cloudflare_worker/package.json diff --git a/crates/cloudflare_worker/src/lib.rs b/bin/cloudflare_worker/src/lib.rs similarity index 96% rename from crates/cloudflare_worker/src/lib.rs rename to bin/cloudflare_worker/src/lib.rs index bf5197b8..38709ab5 100644 --- a/crates/cloudflare_worker/src/lib.rs +++ b/bin/cloudflare_worker/src/lib.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use conductor_common::http::{ ConductorHttpRequest, HeaderName, HeaderValue, HttpHeadersMap, Method, }; -use conductor_config::from_yaml; +use conductor_config::parse_config_from_yaml; use conductor_engine::gateway::ConductorGateway; use std::panic; use tracing_subscriber::fmt::time::UtcTime; @@ -15,7 +15,7 @@ async fn run_flow(mut req: Request, env: Env, _ctx: Context) -> Result let conductor_config_str = env.var("CONDUCTOR_CONFIG").map(|v| v.to_string()); match conductor_config_str { - Ok(conductor_config_str) => match from_yaml(&conductor_config_str) { + Ok(conductor_config_str) => match parse_config_from_yaml(&conductor_config_str) { Ok(conductor_config) => { let gw = ConductorGateway::lazy(conductor_config); diff --git a/crates/cloudflare_worker/wrangler.toml b/bin/cloudflare_worker/wrangler.toml similarity index 100% rename from crates/cloudflare_worker/wrangler.toml rename to bin/cloudflare_worker/wrangler.toml diff --git a/crates/conductor/Cargo.toml b/bin/conductor/Cargo.toml similarity index 67% rename from crates/conductor/Cargo.toml rename to bin/conductor/Cargo.toml index 3576bcc4..3607e92b 100644 --- a/crates/conductor/Cargo.toml +++ b/bin/conductor/Cargo.toml @@ -12,9 +12,9 @@ name = "conductor" path = "src/lib.rs" [dependencies] -conductor_config = { path = "../config" } -conductor_engine = { path = "../engine" } -conductor_common = { path = "../common" } +conductor_config = { path = "../../libs/config" } +conductor_engine = { path = "../../libs/engine" } +conductor_common = { path = "../../libs/common" } actix-web = "4.4.0" tracing = { workspace = true } tracing-subscriber = "0.3.18" diff --git a/crates/conductor/docker/Dockerfile b/bin/conductor/docker/Dockerfile similarity index 100% rename from crates/conductor/docker/Dockerfile rename to bin/conductor/docker/Dockerfile diff --git a/crates/conductor/docker/bake.hcl b/bin/conductor/docker/bake.hcl similarity index 100% rename from crates/conductor/docker/bake.hcl rename to bin/conductor/docker/bake.hcl diff --git a/crates/conductor/src/lib.rs b/bin/conductor/src/lib.rs similarity index 100% rename from crates/conductor/src/lib.rs rename to bin/conductor/src/lib.rs diff --git a/crates/conductor/src/main.rs b/bin/conductor/src/main.rs similarity index 100% rename from crates/conductor/src/main.rs rename to bin/conductor/src/main.rs diff --git a/crates/.DS_Store b/libs/.DS_Store similarity index 100% rename from crates/.DS_Store rename to libs/.DS_Store diff --git a/crates/benches/Cargo.toml b/libs/benches/Cargo.toml similarity index 89% rename from crates/benches/Cargo.toml rename to libs/benches/Cargo.toml index 64be1c8a..16889cf6 100644 --- a/crates/benches/Cargo.toml +++ b/libs/benches/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] criterion = { version = "0.5.1", features = ["html_reports"] } -conductor = { path = "../conductor" } +conductor = { path = "../../bin/conductor" } futures = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/benches/bench.rs b/libs/benches/bench.rs similarity index 100% rename from crates/benches/bench.rs rename to libs/benches/bench.rs diff --git a/crates/benches/config.yaml b/libs/benches/config.yaml similarity index 100% rename from crates/benches/config.yaml rename to libs/benches/config.yaml diff --git a/crates/common/Cargo.toml b/libs/common/Cargo.toml similarity index 100% rename from crates/common/Cargo.toml rename to libs/common/Cargo.toml diff --git a/crates/common/src/graphql.rs b/libs/common/src/graphql.rs similarity index 100% rename from crates/common/src/graphql.rs rename to libs/common/src/graphql.rs diff --git a/crates/common/src/http.rs b/libs/common/src/http.rs similarity index 100% rename from crates/common/src/http.rs rename to libs/common/src/http.rs diff --git a/crates/common/src/json.rs b/libs/common/src/json.rs similarity index 100% rename from crates/common/src/json.rs rename to libs/common/src/json.rs diff --git a/crates/common/src/lib.rs b/libs/common/src/lib.rs similarity index 100% rename from crates/common/src/lib.rs rename to libs/common/src/lib.rs diff --git a/crates/config/Cargo.toml b/libs/config/Cargo.toml similarity index 100% rename from crates/config/Cargo.toml rename to libs/config/Cargo.toml diff --git a/crates/config/conductor.schema.json b/libs/config/conductor.schema.json similarity index 100% rename from crates/config/conductor.schema.json rename to libs/config/conductor.schema.json diff --git a/crates/config/src/generate-json-schema.rs b/libs/config/src/generate-json-schema.rs similarity index 100% rename from crates/config/src/generate-json-schema.rs rename to libs/config/src/generate-json-schema.rs diff --git a/crates/config/src/lib.rs b/libs/config/src/lib.rs similarity index 91% rename from crates/config/src/lib.rs rename to libs/config/src/lib.rs index 8f3a8ce9..0ce2f24c 100644 --- a/crates/config/src/lib.rs +++ b/libs/config/src/lib.rs @@ -150,16 +150,20 @@ pub async fn load_config(file_path: &String) -> ConductorConfig { match path.extension() { Some(ext) => match ext.to_str() { - Some("json") => serde_json::from_str::(&contents) - .expect("Failed to parse config file"), - Some("yaml") | Some("yml") => serde_yaml::from_str::(&contents) - .expect("Failed to parse config file"), + Some("json") => parse_config_from_json(&contents).expect("Failed to parse config file"), + Some("yaml") | Some("yml") => { + parse_config_from_yaml(&contents).expect("Failed to parse config file") + } _ => panic!("Unsupported config file extension"), }, None => panic!("Config file has no extension"), } } -pub fn from_yaml(contents: &str) -> Result { +pub fn parse_config_from_yaml(contents: &str) -> Result { serde_yaml::from_str::(contents) } + +pub fn parse_config_from_json(contents: &str) -> Result { + serde_json::from_str::(contents) +} diff --git a/crates/config/src/plugins.rs b/libs/config/src/plugins.rs similarity index 100% rename from crates/config/src/plugins.rs rename to libs/config/src/plugins.rs diff --git a/crates/config/src/serde_utils.rs b/libs/config/src/serde_utils.rs similarity index 100% rename from crates/config/src/serde_utils.rs rename to libs/config/src/serde_utils.rs diff --git a/crates/engine/Cargo.toml b/libs/engine/Cargo.toml similarity index 89% rename from crates/engine/Cargo.toml rename to libs/engine/Cargo.toml index c2844861..2d10fe50 100644 --- a/crates/engine/Cargo.toml +++ b/libs/engine/Cargo.toml @@ -14,6 +14,6 @@ async-trait = { workspace = true } thiserror = { workspace = true } conductor_common = { path = "../common" } conductor_config = { path = "../config" } -async_runtime = { path = "../async_runtime" } +wasm_polyfills = { path = "../wasm_polyfills" } matchit = "0.7.3" reqwest = { workspace = true } diff --git a/crates/engine/src/endpoint_runtime.rs b/libs/engine/src/endpoint_runtime.rs similarity index 100% rename from crates/engine/src/endpoint_runtime.rs rename to libs/engine/src/endpoint_runtime.rs diff --git a/crates/engine/src/gateway.rs b/libs/engine/src/gateway.rs similarity index 100% rename from crates/engine/src/gateway.rs rename to libs/engine/src/gateway.rs diff --git a/crates/engine/src/lib.rs b/libs/engine/src/lib.rs similarity index 100% rename from crates/engine/src/lib.rs rename to libs/engine/src/lib.rs diff --git a/crates/engine/src/plugins/core.rs b/libs/engine/src/plugins/core.rs similarity index 100% rename from crates/engine/src/plugins/core.rs rename to libs/engine/src/plugins/core.rs diff --git a/crates/engine/src/plugins/graphiql_plugin.rs b/libs/engine/src/plugins/graphiql_plugin.rs similarity index 100% rename from crates/engine/src/plugins/graphiql_plugin.rs rename to libs/engine/src/plugins/graphiql_plugin.rs diff --git a/crates/engine/src/plugins/http_get_plugin.rs b/libs/engine/src/plugins/http_get_plugin.rs similarity index 100% rename from crates/engine/src/plugins/http_get_plugin.rs rename to libs/engine/src/plugins/http_get_plugin.rs diff --git a/crates/engine/src/plugins/match_content_type.rs b/libs/engine/src/plugins/match_content_type.rs similarity index 100% rename from crates/engine/src/plugins/match_content_type.rs rename to libs/engine/src/plugins/match_content_type.rs diff --git a/crates/engine/src/plugins/mod.rs b/libs/engine/src/plugins/mod.rs similarity index 100% rename from crates/engine/src/plugins/mod.rs rename to libs/engine/src/plugins/mod.rs diff --git a/crates/engine/src/plugins/persisted_documents/config.rs b/libs/engine/src/plugins/persisted_documents/config.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/config.rs rename to libs/engine/src/plugins/persisted_documents/config.rs diff --git a/crates/engine/src/plugins/persisted_documents/mod.rs b/libs/engine/src/plugins/persisted_documents/mod.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/mod.rs rename to libs/engine/src/plugins/persisted_documents/mod.rs diff --git a/crates/engine/src/plugins/persisted_documents/plugin.rs b/libs/engine/src/plugins/persisted_documents/plugin.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/plugin.rs rename to libs/engine/src/plugins/persisted_documents/plugin.rs diff --git a/crates/engine/src/plugins/persisted_documents/protocols/apollo_manifest.rs b/libs/engine/src/plugins/persisted_documents/protocols/apollo_manifest.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/protocols/apollo_manifest.rs rename to libs/engine/src/plugins/persisted_documents/protocols/apollo_manifest.rs diff --git a/crates/engine/src/plugins/persisted_documents/protocols/document_id.rs b/libs/engine/src/plugins/persisted_documents/protocols/document_id.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/protocols/document_id.rs rename to libs/engine/src/plugins/persisted_documents/protocols/document_id.rs diff --git a/crates/engine/src/plugins/persisted_documents/protocols/get_handler.rs b/libs/engine/src/plugins/persisted_documents/protocols/get_handler.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/protocols/get_handler.rs rename to libs/engine/src/plugins/persisted_documents/protocols/get_handler.rs diff --git a/crates/engine/src/plugins/persisted_documents/protocols/mod.rs b/libs/engine/src/plugins/persisted_documents/protocols/mod.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/protocols/mod.rs rename to libs/engine/src/plugins/persisted_documents/protocols/mod.rs diff --git a/crates/engine/src/plugins/persisted_documents/store/fs.rs b/libs/engine/src/plugins/persisted_documents/store/fs.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/store/fs.rs rename to libs/engine/src/plugins/persisted_documents/store/fs.rs diff --git a/crates/engine/src/plugins/persisted_documents/store/mod.rs b/libs/engine/src/plugins/persisted_documents/store/mod.rs similarity index 100% rename from crates/engine/src/plugins/persisted_documents/store/mod.rs rename to libs/engine/src/plugins/persisted_documents/store/mod.rs diff --git a/crates/engine/src/plugins/plugin_manager.rs b/libs/engine/src/plugins/plugin_manager.rs similarity index 100% rename from crates/engine/src/plugins/plugin_manager.rs rename to libs/engine/src/plugins/plugin_manager.rs diff --git a/crates/engine/src/request_execution_context.rs b/libs/engine/src/request_execution_context.rs similarity index 100% rename from crates/engine/src/request_execution_context.rs rename to libs/engine/src/request_execution_context.rs diff --git a/crates/engine/src/source/graphql_source.rs b/libs/engine/src/source/graphql_source.rs similarity index 93% rename from crates/engine/src/source/graphql_source.rs rename to libs/engine/src/source/graphql_source.rs index abd4267f..f68edca1 100644 --- a/crates/engine/src/source/graphql_source.rs +++ b/libs/engine/src/source/graphql_source.rs @@ -1,7 +1,5 @@ use std::{future::Future, pin::Pin}; -use async_runtime::{call_async, create_http_client}; - use conductor_common::{graphql::GraphQLResponse, http::Bytes}; use conductor_config::GraphQLSourceConfig; use reqwest::{Client, Method, StatusCode}; @@ -20,7 +18,7 @@ pub struct GraphQLSourceRuntime { impl GraphQLSourceRuntime { pub fn new(config: GraphQLSourceConfig) -> Self { - let fetcher = create_http_client().build().unwrap(); + let fetcher = wasm_polyfills::create_http_client().build().unwrap(); Self { fetcher, config } } @@ -36,7 +34,7 @@ impl SourceRuntime for GraphQLSourceRuntime { route_data: &'a ConductorGatewayRouteData, request_context: &'a mut RequestExecutionContext<'_>, ) -> Pin> + Send + 'a)>> { - Box::pin(call_async(async move { + Box::pin(wasm_polyfills::call_async(async move { let fetcher = &self.fetcher; let endpoint = &self.config.endpoint; let source_req = &mut request_context diff --git a/crates/engine/src/source/mod.rs b/libs/engine/src/source/mod.rs similarity index 100% rename from crates/engine/src/source/mod.rs rename to libs/engine/src/source/mod.rs diff --git a/crates/engine/src/source/runtime.rs b/libs/engine/src/source/runtime.rs similarity index 100% rename from crates/engine/src/source/runtime.rs rename to libs/engine/src/source/runtime.rs diff --git a/crates/async_runtime/Cargo.toml b/libs/wasm_polyfills/Cargo.toml similarity index 94% rename from crates/async_runtime/Cargo.toml rename to libs/wasm_polyfills/Cargo.toml index 5b388f87..fcfd502e 100644 --- a/crates/async_runtime/Cargo.toml +++ b/libs/wasm_polyfills/Cargo.toml @@ -1,6 +1,5 @@ - [package] -name = "async_runtime" +name = "wasm_polyfills" version = "0.0.0" edition = "2021" diff --git a/crates/async_runtime/src/lib.rs b/libs/wasm_polyfills/src/lib.rs similarity index 100% rename from crates/async_runtime/src/lib.rs rename to libs/wasm_polyfills/src/lib.rs diff --git a/test_config/config.yaml b/test_config/config.yaml index 9ce4cc36..2b543c82 100644 --- a/test_config/config.yaml +++ b/test_config/config.yaml @@ -1,5 +1,5 @@ server: - port: 9000 + port: 8000 logger: level: debug @@ -32,7 +32,7 @@ endpoints: name: docId variables_from: source: header - name: "X-GraphQL-Variables" + name: 'X-GraphQL-Variables' allow_non_persisted: true - path: /test From ea22a2242da0830d755d95221d69d564494518df Mon Sep 17 00:00:00 2001 From: YassinEldeeb Date: Sun, 19 Nov 2023 06:37:39 +0200 Subject: [PATCH 2/8] cleanup openssl dep --- Cargo.lock | 11 ----------- bin/conductor/Cargo.toml | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ce08e99..e91a4e28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -505,7 +505,6 @@ dependencies = [ "conductor_common", "conductor_config", "conductor_engine", - "openssl", "tracing", "tracing-subscriber", ] @@ -1340,15 +1339,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-src" -version = "300.1.6+3.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439fac53e092cd7442a3660c85dde4643ab3b5bd39040912388dcdabf6b88085" -dependencies = [ - "cc", -] - [[package]] name = "openssl-sys" version = "0.9.95" @@ -1357,7 +1347,6 @@ checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" dependencies = [ "cc", "libc", - "openssl-src", "pkg-config", "vcpkg", ] diff --git a/bin/conductor/Cargo.toml b/bin/conductor/Cargo.toml index 3607e92b..a1744792 100644 --- a/bin/conductor/Cargo.toml +++ b/bin/conductor/Cargo.toml @@ -17,5 +17,4 @@ conductor_engine = { path = "../../libs/engine" } conductor_common = { path = "../../libs/common" } actix-web = "4.4.0" tracing = { workspace = true } -tracing-subscriber = "0.3.18" -openssl = { version = "0.10", features = ["vendored"] } +tracing-subscriber = "0.3.18" \ No newline at end of file From d257bd43e383c78582c8a610139ce7f3fd895c80 Mon Sep 17 00:00:00 2001 From: Dotan Simha Date: Sun, 19 Nov 2023 09:06:02 +0200 Subject: [PATCH 3/8] Delete libs/.DS_Store --- libs/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 libs/.DS_Store diff --git a/libs/.DS_Store b/libs/.DS_Store deleted file mode 100644 index 399a3b03ec0a3bc42ce0d1eea7edab94fc61f7c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOG*P#5UkcL0z$~r<-3A67(zTj4xnJfjm|(~T+hmLd9+l25Qd51#*I`%cfHrs z^&V4;>1hDAIqmO&HGn1E5uYCB=Fi<{c2yZ8(s{-SPk6_G10H78mlMuiku{*le!_pl zGmbcZ><<0w(7)szmk&`^3P=GdAO)m=6!^6Q-g{}wn?yw^AO)nrw*vlsXmrP}a7>I( z2Sbbi#0Aq~T*oXyY@Q%?g<~Q!G)pQmsa7L~C7tbTA67S8O(+((^ZXX& zur5(i3P^#e0@t}+d;h&%44gG3d+(ov5Dy*F`1;{#t=E Date: Sun, 19 Nov 2023 09:08:04 +0200 Subject: [PATCH 4/8] fix --- .dockerignore | 3 +-- .gitignore | 3 +++ Cargo.lock | 11 +++++++++++ bin/conductor/Cargo.toml | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 0e61d5a2..cd0e712a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,5 +3,4 @@ benches temp tests -renovate.json -temp \ No newline at end of file +renovate.json \ No newline at end of file diff --git a/.gitignore b/.gitignore index f848db74..1d884bd0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ temp node_modules **/node_modules/** +.DS_Store +build +out \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e91a4e28..1ce08e99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -505,6 +505,7 @@ dependencies = [ "conductor_common", "conductor_config", "conductor_engine", + "openssl", "tracing", "tracing-subscriber", ] @@ -1339,6 +1340,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.1.6+3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439fac53e092cd7442a3660c85dde4643ab3b5bd39040912388dcdabf6b88085" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.95" @@ -1347,6 +1357,7 @@ checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/bin/conductor/Cargo.toml b/bin/conductor/Cargo.toml index a1744792..3607e92b 100644 --- a/bin/conductor/Cargo.toml +++ b/bin/conductor/Cargo.toml @@ -17,4 +17,5 @@ conductor_engine = { path = "../../libs/engine" } conductor_common = { path = "../../libs/common" } actix-web = "4.4.0" tracing = { workspace = true } -tracing-subscriber = "0.3.18" \ No newline at end of file +tracing-subscriber = "0.3.18" +openssl = { version = "0.10", features = ["vendored"] } From da742cf234b929f32cb11f2ca95340a3fff20778 Mon Sep 17 00:00:00 2001 From: Dotan Simha Date: Sun, 19 Nov 2023 09:10:35 +0200 Subject: [PATCH 5/8] fixes for ci --- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yaml | 2 +- .vscode/settings.json | 2 +- bin/conductor/docker/Dockerfile | 10 +++++----- bin/conductor/docker/bake.hcl | 2 +- libs/config/src/generate-json-schema.rs | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 748ed124..1476884f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -92,7 +92,7 @@ jobs: run: cargo run --bin generate-config-schema - name: check diff - run: git diff --exit-code ./crates/config/conductor.schema.json + run: git diff --exit-code ./libs/config/conductor.schema.json lint: runs-on: ubuntu-22.04 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c48e6e2b..df2c3e75 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -44,7 +44,7 @@ jobs: workdir: . provenance: false push: true - files: ./crates/conductor/docker/bake.hcl + files: ./bin/conductor/docker/bake.hcl targets: build set: | *.cache-from=type=gha,scope=build diff --git a/.vscode/settings.json b/.vscode/settings.json index 8f6d5e18..b79c6958 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "yaml.schemas": { - "./crates/config/conductor.schema.json": "*.yaml" + "./libs/config/conductor.schema.json": "*.yaml" }, "rust-analyzer.linkedProjects": ["./Cargo.toml"] } diff --git a/bin/conductor/docker/Dockerfile b/bin/conductor/docker/Dockerfile index 97f73784..2a963cd7 100644 --- a/bin/conductor/docker/Dockerfile +++ b/bin/conductor/docker/Dockerfile @@ -6,16 +6,16 @@ COPY Cargo.toml Cargo.lock ./ # This is a trick to get the most out of Docker's caching mechanism in GH Actions. COPY crates crates RUN rm -rf crates/benches -RUN echo 'fn main() { println!("Dummy!"); }' > ./crates/conductor/src/main.rs -RUN echo 'fn main() { println!("Dummy!"); }' > ./crates/conductor/src/lib.rs +RUN echo 'fn main() { println!("Dummy!"); }' > ./libs/conductor/src/main.rs +RUN echo 'fn main() { println!("Dummy!"); }' > ./libs/conductor/src/lib.rs # We are only building the dependencies here, with a dummy file, this compiles all dependencies code only. RUN cargo build --release --bin conductor # Now we can remove the dummy code, copy the actual code and compile the user code. # This ensures that building dependencies and the actual code are cached separately. -COPY crates/conductor/src/main.rs crates/conductor/src/main.rs -COPY crates/conductor/src/lib.rs crates/conductor/src/lib.rs -RUN touch crates/conductor/src/main.rs crates/conductor/src/lib.rs +COPY libs/conductor/src/main.rs libs/conductor/src/main.rs +COPY libs/conductor/src/lib.rs libs/conductor/src/lib.rs +RUN touch libs/conductor/src/main.rs libs/conductor/src/lib.rs RUN cargo build --release --bin conductor FROM debian:12.2 diff --git a/bin/conductor/docker/bake.hcl b/bin/conductor/docker/bake.hcl index 7f4532a2..40d20ea4 100644 --- a/bin/conductor/docker/bake.hcl +++ b/bin/conductor/docker/bake.hcl @@ -33,7 +33,7 @@ function "commit_id_tag" { target "conductor" { context = "./" - dockerfile = "./crates/conductor/docker/Dockerfile" + dockerfile = "./libs/conductor/docker/Dockerfile" tags = [ commit_id_tag("conductor", COMMIT_SHA), maybe_latest_image_tag("conductor"), diff --git a/libs/config/src/generate-json-schema.rs b/libs/config/src/generate-json-schema.rs index d0c6ba32..a3dfc9e6 100644 --- a/libs/config/src/generate-json-schema.rs +++ b/libs/config/src/generate-json-schema.rs @@ -5,7 +5,7 @@ pub fn main() { println!("⚙️ Generating JSON schema for Conductor config file..."); let schema = schema_for!(ConductorConfig); let as_string = serde_json::to_string_pretty(&schema).unwrap(); - println!("✏️ Writing to: crates/config/conductor.schema.json"); - std::fs::write("crates/config/conductor.schema.json", as_string).unwrap(); + println!("✏️ Writing to: libs/config/conductor.schema.json"); + std::fs::write("libs/config/conductor.schema.json", as_string).unwrap(); println!("✅ Done"); } From 014187ad625635dbe757587ac4ef10b3003b6e33 Mon Sep 17 00:00:00 2001 From: Dotan Simha Date: Sun, 19 Nov 2023 09:11:58 +0200 Subject: [PATCH 6/8] fix --- bin/conductor/docker/Dockerfile | 10 +++++----- bin/conductor/docker/bake.hcl | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/conductor/docker/Dockerfile b/bin/conductor/docker/Dockerfile index 2a963cd7..a0750c69 100644 --- a/bin/conductor/docker/Dockerfile +++ b/bin/conductor/docker/Dockerfile @@ -6,16 +6,16 @@ COPY Cargo.toml Cargo.lock ./ # This is a trick to get the most out of Docker's caching mechanism in GH Actions. COPY crates crates RUN rm -rf crates/benches -RUN echo 'fn main() { println!("Dummy!"); }' > ./libs/conductor/src/main.rs -RUN echo 'fn main() { println!("Dummy!"); }' > ./libs/conductor/src/lib.rs +RUN echo 'fn main() { println!("Dummy!"); }' > ./bin/conductor/src/main.rs +RUN echo 'fn main() { println!("Dummy!"); }' > ./bin/conductor/src/lib.rs # We are only building the dependencies here, with a dummy file, this compiles all dependencies code only. RUN cargo build --release --bin conductor # Now we can remove the dummy code, copy the actual code and compile the user code. # This ensures that building dependencies and the actual code are cached separately. -COPY libs/conductor/src/main.rs libs/conductor/src/main.rs -COPY libs/conductor/src/lib.rs libs/conductor/src/lib.rs -RUN touch libs/conductor/src/main.rs libs/conductor/src/lib.rs +COPY bin/conductor/src/main.rs bin/conductor/src/main.rs +COPY bin/conductor/src/lib.rs bin/conductor/src/lib.rs +RUN touch bin/conductor/src/main.rs bin/conductor/src/lib.rs RUN cargo build --release --bin conductor FROM debian:12.2 diff --git a/bin/conductor/docker/bake.hcl b/bin/conductor/docker/bake.hcl index 40d20ea4..b431e79e 100644 --- a/bin/conductor/docker/bake.hcl +++ b/bin/conductor/docker/bake.hcl @@ -33,7 +33,7 @@ function "commit_id_tag" { target "conductor" { context = "./" - dockerfile = "./libs/conductor/docker/Dockerfile" + dockerfile = "./bin/conductor/docker/Dockerfile" tags = [ commit_id_tag("conductor", COMMIT_SHA), maybe_latest_image_tag("conductor"), From 60dd02e795908f5df3702fc353e5a95f9588112b Mon Sep 17 00:00:00 2001 From: Dotan Simha Date: Sun, 19 Nov 2023 09:12:53 +0200 Subject: [PATCH 7/8] fixes --- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yaml | 6 +++--- bin/conductor/docker/Dockerfile | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1476884f..a90f184a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,7 +32,7 @@ jobs: run: cargo build --bin conductor --release - name: "build (bin: cloudflare_worker_wasm)" - working-directory: crates/cloudflare_worker + working-directory: bin/cloudflare_worker run: cargo install -q worker-build && worker-build - name: test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index df2c3e75..c1fde195 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -90,7 +90,7 @@ jobs: override: true - name: "build (bin: cloudflare_worker_wasm)" - working-directory: crates/cloudflare_worker + working-directory: bin/cloudflare_worker run: cargo install -q worker-build && worker-build --release - uses: actions/upload-artifact@v3 @@ -98,13 +98,13 @@ jobs: name: upload wasm artifact with: name: conductor-cf-worker-wasm - path: crates/cloudflare_worker/build/ + path: bin/cloudflare_worker/build/ - uses: montudor/action-zip@v1 name: zip wasm artifact if: ${{ github.event_name == 'release' }} with: - args: zip -qq -r cloudflare-worker-wasm.zip crates/cloudflare_worker/build/ + args: zip -qq -r cloudflare-worker-wasm.zip bin/cloudflare_worker/build/ - name: upload wasm to release if: ${{ github.event_name == 'release' }} diff --git a/bin/conductor/docker/Dockerfile b/bin/conductor/docker/Dockerfile index a0750c69..7596637a 100644 --- a/bin/conductor/docker/Dockerfile +++ b/bin/conductor/docker/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /usr/src/conductor COPY Cargo.toml Cargo.lock ./ # This is a trick to get the most out of Docker's caching mechanism in GH Actions. -COPY crates crates -RUN rm -rf crates/benches +COPY libs libs +COPY bin bin +RUN rm -rf lib/benches RUN echo 'fn main() { println!("Dummy!"); }' > ./bin/conductor/src/main.rs RUN echo 'fn main() { println!("Dummy!"); }' > ./bin/conductor/src/lib.rs # We are only building the dependencies here, with a dummy file, this compiles all dependencies code only. From a365171d1bafed7abff120040b7f78cb900d1a47 Mon Sep 17 00:00:00 2001 From: Dotan Simha Date: Sun, 19 Nov 2023 10:31:51 +0200 Subject: [PATCH 8/8] fix routing issues --- bin/conductor/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/conductor/src/lib.rs b/bin/conductor/src/lib.rs index 5cf0f886..1807c933 100644 --- a/bin/conductor/src/lib.rs +++ b/bin/conductor/src/lib.rs @@ -50,7 +50,8 @@ fn create_router_from_config( &mut |route_data, app, path| { let child_router = Scope::new(path.as_str()) .app_data(web::Data::new(route_data)) - .route("/.*", web::route().to(handler)); + .route("{tail:.*}", web::route().to(handler)) + .route("", web::route().to(handler)); app.service(child_router) },