Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
benches
temp
tests
renovate.json
temp
renovate.json
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,21 +90,21 @@ 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
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
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' }}
Expand Down Expand Up @@ -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' }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
temp
node_modules
**/node_modules/**
.DS_Store
build
out
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"yaml.schemas": {
"./crates/config/conductor.schema.json": "*.yaml"
"./libs/config/conductor.schema.json": "*.yaml"
},
"rust-analyzer.linkedProjects": ["./Cargo.toml"]
}
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["crates/*"]
members = ["libs/*", "bin/*"]
resolver = "2"

[workspace.dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@ async fn run_flow(mut req: Request, env: Env, _ctx: Context) -> Result<Response>
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);

Expand Down
6 changes: 3 additions & 3 deletions crates/conductor/Cargo.toml → bin/conductor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ 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
RUN echo 'fn main() { println!("Dummy!"); }' > ./crates/conductor/src/main.rs
RUN echo 'fn main() { println!("Dummy!"); }' > ./crates/conductor/src/lib.rs
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.
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 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function "commit_id_tag" {

target "conductor" {
context = "./"
dockerfile = "./crates/conductor/docker/Dockerfile"
dockerfile = "./bin/conductor/docker/Dockerfile"
tags = [
commit_id_tag("conductor", COMMIT_SHA),
maybe_latest_image_tag("conductor"),
Expand Down
3 changes: 2 additions & 1 deletion crates/conductor/src/lib.rs → bin/conductor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down
File renamed without changes.
Binary file removed crates/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion crates/benches/Cargo.toml → libs/benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
14 changes: 9 additions & 5 deletions crates/config/src/lib.rs → libs/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ConductorConfig>(&contents)
.expect("Failed to parse config file"),
Some("yaml") | Some("yml") => serde_yaml::from_str::<ConductorConfig>(&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<ConductorConfig, serde_yaml::Error> {
pub fn parse_config_from_yaml(contents: &str) -> Result<ConductorConfig, serde_yaml::Error> {
serde_yaml::from_str::<ConductorConfig>(contents)
}

pub fn parse_config_from_json(contents: &str) -> Result<ConductorConfig, serde_json::Error> {
serde_json::from_str::<ConductorConfig>(contents)
}
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/engine/Cargo.toml → libs/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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 }
}
Expand All @@ -36,7 +34,7 @@ impl SourceRuntime for GraphQLSourceRuntime {
route_data: &'a ConductorGatewayRouteData,
request_context: &'a mut RequestExecutionContext<'_>,
) -> Pin<Box<(dyn Future<Output = Result<GraphQLResponse, SourceError>> + 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

[package]
name = "async_runtime"
name = "wasm_polyfills"
version = "0.0.0"
edition = "2021"

Expand Down
4 changes: 2 additions & 2 deletions test_config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server:
port: 9000
port: 8000

logger:
level: debug
Expand Down Expand Up @@ -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
Expand Down