feat(rs-dapi-client): make health check cross-platform (native + WASM)#3371
feat(rs-dapi-client): make health check cross-platform (native + WASM)#3371lklimek merged 3 commits intofeat/sdk-health-checkfrom
Conversation
…ASM targets Replace tokio-specific primitives with runtime-agnostic alternatives so the health_check module is no longer gated behind #[cfg(not(target_arch = "wasm32"))]. - Use futures::select_biased! instead of tokio::select! - cfg-gate only the sleep import (tokio::time::sleep vs gloo_timers::future::sleep) - Move tokio-util to non-gated deps (CancellationToken needs no runtime) - Split run_health_check into a thin public wrapper + inner health_check_loop that takes a generic stop future - Add WASM health check spawning via wasm_bindgen_futures::spawn_local in rs-sdk - Expose withHealthCheck() builder method in wasm-sdk - Remove #[cfg(not(wasm32))] gates from health_check module and HealthCheckConfig export Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ DashSDKFFI.xcframework built for this PR.
SwiftPM (host the zip at a stable URL, then use): .binaryTarget(
name: "DashSDKFFI",
url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
checksum: "3472d896bdea8e9c095db4a686879be8aa45f50ee21ce3184ff10bb58bb6efce"
)Xcode manual integration:
|
Resolve conflicts: - health_check.rs: combine WASM cross-platform structure (select_biased!, gloo_timers) with expired-ban-before-sleep fix from base - sdk.rs: remove pre-extracted hc_* variables, use start_health_check() - Make start_health_check() cross-platform (tokio::spawn vs spawn_local) - Remove cfg gate from build() health check init Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Issue being fixed or feature implemented
Makes the background health check from #3353 compile and run on both native (tokio) and WASM (browser) targets, enabling health checks in the JS/WASM SDK.
What was done?
rs-dapi-client/src/health_check.rs:run_health_check()(public, takesCancellationToken) delegates tohealth_check_loop()(runtime-agnostic, takesimpl Future<Output=()>)tokio::select!withfutures::select_biased!+FusedFuturefor cross-platform compatibilitygloo_timers::future::sleep(WASM) vstokio::time::sleep(native)OptionalCertificatetype alias:Option<Certificate>on native,Option<()>on WASMrs-dapi-client/src/lib.rs:#[cfg(not(target_arch = "wasm32"))]fromhealth_checkmodule andHealthCheckConfigexportrs-dapi-client/Cargo.toml:tokio-utilto non-gated deps withdefault-features = falsers-sdk/src/sdk.rs:start_health_check()now works on both platforms (tokio::spawn vs wasm_bindgen_futures::spawn_local)build()uses single non-gatedsdk.start_health_check()call — no duplicated spawn logicArc<ArcSwapOption<CancellationToken>>withArc<Mutex<CancellationToken>>— simpler, no extra dep needed, token state is the state machine (cancelled = stopped, live = running)stop_health_check(),is_health_check_running()for runtime controlDropimpl and_health_check_handlefield — lifecycle managed by CancellationTokenHow Has This Been Tested?
cargo clippy -p dash-sdk -p rs-dapi-client— cleancargo test -p dash-sdk --lib— 84 passedcargo test -p rs-dapi-client— all passedBreaking Changes
None. Public API additions only (
start_health_check,stop_health_check,is_health_check_running).Checklist:
🤖 Co-authored by Claudius the Magnificent AI Agent