Repository navigation
refactor(query-engine): extract asap-adapters crate - #936
milindsrivastava1997 wants to merge 2 commits into
Conversation
Move protocol adapters, fallback clients, the OTLP receiver, the query tracker, planner client and every binary into a new workspace crate that depends on the engine crate. The engine crate becomes a library and no longer depends on asap-planner-rs. The Prometheus and VictoriaMetrics remote-write decoders stay in the engine crate: precompute_engine's ingest sources use DecodedSample and the decoders, and those sources use precompute internals. Imports, manifests, Dockerfiles, install script and CI path filters only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aths Remove reqwest, rusqlite, uuid and structopt from the engine manifest; nothing in the crate uses them. Point asap-tools build/edit instructions at asap-adapters and the manual-stack docs at the workspace target dir. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
milindsrivastava1997
left a comment
There was a problem hiding this comment.
Code review findings (Claude Code). Comments that couldn't be anchored to diff lines:
- [nit]
asap-tools/docs/deployment.md: line 234 still sayscd asap-query-engine; cargo build --release # Compile Rust binary, and line 308 sayscd $REPO_ROOT/asap-query-engine; touch src/main.rsto force a rebuild. asap-query-engine no longer has a binary or asrc/main.rs, and thetouchwould create a stray file that cargo picks up as a new bin target. Point both at asap-adapters. - [nit] Stale
engine_config.rs/ driver references:asap-tools/experiments/experiment_utils/services/query_engine.py(lines 135, 277) andasap-tools/experiments/config/config.yaml(line 78) still point atasap-query-engine/src/engine_config.rs, which now lives inasap-adapters/src/engine_config.rs.asap-query-engine/docs/adding-fallback-backend.mdandadding-protocol-server.mdstill describecrate::drivers::querycode that is now in asap-adapters.
| "asap-common/tests/compare_matched_tokens/rust_tests", | ||
| "asap-common/tests/compare_patterns", | ||
| "asap-query-engine", | ||
| "asap-adapters", |
There was a problem hiding this comment.
[important] CloudLab deploys can no longer build any Rust crate. asap-adapters is now a workspace member, but it isn't in asap-tools/components.conf, so rsync.sh / deploy_changes.sh never sync it. The root Cargo.toml is synced (via root_files.conf), so on the node cargo build --release -p asap-adapters in asap-query-engine/installation/install.sh fails with failed to load manifest for workspace member asap-adapters. The asap-planner-rs and rqe-optimizer installs fail the same way. Editing asap-adapters/src/main.rs also never triggers a reinstall, contrary to the updated README flow.
Fix: add asap-adapters to components.conf and give it an installation/install.sh, or make a change to asap-adapters reinstall asap-query-engine.
|
|
||
| 2. Ensure the release binaries are built on the CloudLab node: | ||
| cargo build --release (in ~/code/asap-query-engine) | ||
| cargo build --release (in ~/code/asap-adapters) |
There was a problem hiding this comment.
[important] This docstring says to run cargo build --release in ~/code/asap-adapters on the CloudLab node. That directory is never synced there because it is missing from components.conf (see the comment on root Cargo.toml), so cd ~/code/asap-adapters fails on a freshly synced node.
| [dev-dependencies] | ||
| serde_yaml.workspace = true | ||
|
|
||
| [features] |
There was a problem hiding this comment.
[important] You can no longer turn the query_engine_rust cargo features on or off from the server binaries. asap-adapters depends on query_engine_rust with its default features and only forwards native_query_legacy_test_support. So cargo build -p asap-adapters --features lock_profiling errors with 'does not have feature', and --no-default-features still links jemalloc. Both worked with -p query_engine_rust before this PR.
Fix: add forwarding features and depend with default-features = false:
[features]
default = ["jemalloc"]
jemalloc = ["query_engine_rust/jemalloc"]
lock_profiling = ["query_engine_rust/lock_profiling"]
extra_debugging = ["query_engine_rust/extra_debugging"]| # Build dependencies (this layer will be cached) | ||
| WORKDIR /code/asap-query-engine | ||
| RUN cargo build --release && rm -rf src/ | ||
| WORKDIR /code/asap-adapters |
There was a problem hiding this comment.
[nit] cargo now runs from /code/asap-adapters, so builds there (local and CloudLab, per the updated HANDOFF.md / sweep.py) no longer pick up asap-query-engine/.cargo/config.toml (git-fetch-with-cli = true). Consider moving that setting to a workspace-root .cargo/config.toml.
| ## Prerequisites | ||
|
|
||
| - asap-query-engine built at `~/code/asap-query-engine/target/release/query_engine_rust` | ||
| - asap-query-engine built at `~/code/target/release/query_engine_rust` (workspace target dir) |
There was a problem hiding this comment.
[nit] This line now points at ~/code/target/release/query_engine_rust, but later steps here (~line 153) and in manual-stack-run-clickhouse.md (~line 172) still run cd ~/code/asap-query-engine && ./target/release/query_engine_rust. That path no longer exists, so those commands fail.
| tracing-appender = "0.2" | ||
| figment = { version = "0.10", features = ["yaml"] } | ||
|
|
||
| [[bin]] |
There was a problem hiding this comment.
[nit] The bin target query_engine_rust has the same name as the lib dependency query_engine_rust, so cargo doc --workspace warns about an output filename collision, and one crate's docs overwrite the other's. Setting doc = false on the bin targets avoids it.
| @@ -1 +1,2 @@ | |||
| #!/bin/bash | |||
| cargo run --bin test_offline_precomputes -- --input-file <msgpack_file_path> --mode merge --pattern-type temporal --aggregation-type DatasketchesKLL --window-size 90 --iterations 10 --slide-step 5 | |||
There was a problem hiding this comment.
[pre-existing] This script runs cargo run --bin test_offline_precomputes, and no such binary exists in either crate. Consider deleting the script or pointing it at a real binary.
Plan step 1 of
.design_docs/asapplanner-engine-boundaries.md(decision 46): extractasap-adaptersas a pure move.What moved to
asap-adaptersdrivers/query/(protocol adapters, fallback clients,HttpServer) anddrivers/ingest/otel.rs(OtlpReceiver)query_tracker/,planner_client.rs(with the asap-planner-rs dependency)main.rs,engine_config.rs(only used bymain.rs) and everysrc/bin/*binary. Binary names are unchanged.HttpServer:rqe_query_tests,{prometheus,clickhouse,elastic}_forwarding_testsasap-query-engineis now a library and no longer depends on asap-planner-rs.Deviations from the plan
drivers/ingest/{prometheus_remote_write,victoriametrics_remote_write}.rs).precompute_engine/{ingest_source,csv_ingest,json_ingest,ingest_handler}.rsuseDecodedSampleand the decoders, and they also use precompute internals (SeriesRouter,pub(crate) route_decoded_samples). Moving the decoders would create a crate cycle, and moving the ingest sources would require visibility changes. Both move together in the wiring step, as the plan already says for the ingest sources.tests/sql_query_support.rsandtests/e2e_precompute_equivalence.rsmove toasap-adapters/tests/. The alternative was to keep asap-planner-rs as an engine dev-dependency. Moving them keeps the engine crate free of any planner dependency, as decision 46 requires. Both tests use only public engine APIs.asap-adapters/src/bin/run.shgets a shebang so shellcheck passes on the moved file. It refers to a binary that no longer exists, so it is dead either way.Other changes (build config only)
Cargo.toml: new member, plus aquery_engine_rustworkspace dependency.rusqlite,uuid,structopt) stay in the engine manifest untouched.asap-adaptersforwardsnative_query_legacy_test_supportto the engine. The defaultjemallocfeature stays on the engine library.asap-query-engine/Dockerfilebuilds fromasap-adapterswith stubs for the new layout.asap-planner-rs/Dockerfilestubs the new member.asap-query-engine/installation/install.sh:-p query_engine_rust→-p asap-adapters.asap-adapters/**.asap-quickstart/Dockerfile.queryengine-localis unchanged: it copies a prebuiltquery_engine_rustbinary, and that name is the same.No logic changes. Imports were rewritten from
crate::toquery_engine_rust::/asap_adapters::, andcargo fmtreordered them.Verification
cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --all-features --locked -- -D warningspass.cargo test --workspace --locked: 1529 passed, 0 failed, the same count asmain.docker build -f asap-query-engine/Dockerfile .and-f asap-planner-rs/Dockerfile .both succeed. The image contains/usr/local/bin/query_engine_rustand--helpruns.Follow-ups (not in this PR)
asap-query-engine/docs/adding-{protocol-adapter,protocol-server,fallback-backend}.mdanddocs/README.mdstill givesrc/drivers/...paths relative to the engine crate.pub(crate).🤖 Generated with Claude Code