openrpc_client!: SSE streaming + multi-domain bundle support on wasm/gloo-net #147

Open
opened 2026-06-02 10:48:03 +00:00 by timur · 0 comments
Owner

Follow-up to the wasm/Dioxus support added for openrpc_client! (target-gated herolib_openrpc transport + generated Client::new(base_url) for wasm32).

Two pieces were intentionally deferred from v1 and are native-only today:

1. SSE streaming on wasm

The generated events() / subscribe_events_at() and the per-method x-sse helpers (*_events, follow_*_sse, collect_*_sse) are #[cfg(not(target_arch = "wasm32"))]. The native path uses hyper/tokio SSE-over-UDS (crates/openrpc/src/sse.rs), which can't run in the browser.

Task: add a browser SSE transport using gloo-net's EventSource (feature eventsource), expose it on the wasm OpenRpcTransport as sse_subscribe, and drop the wasm gate on the generated SSE helpers so they emit on both targets. Keep SseEvent shared across targets.

2. Multi-domain bundle on wasm

The directory-form bundle (openrpc_client!("dir", service = "...")HeroDemoClient with .dom1()/.dom2()) connects over Unix sockets; its connect() is #[cfg(not(target_arch = "wasm32"))]. The inner per-domain clients already get a wasm new(base_url).

Task: add a wasm bundle new(base_url) that builds each domain client over HTTP, once the hero_router per-domain URL convention is confirmed (e.g. {base_url}/<service>_<domain>/rpc vs {base_url}/<domain>/rpc).

Pointers

  • Transport: crates/openrpc/src/transport/openrpc.rs (native + wasm OpenRpcTransport)
  • Macro: crates/derive/src/openrpc_client.rs (generate_client_code, generate_client_bundle)
  • Deps: crates/openrpc/Cargo.toml (target-gated gloo-net)
Follow-up to the wasm/Dioxus support added for `openrpc_client!` (target-gated `herolib_openrpc` transport + generated `Client::new(base_url)` for wasm32). Two pieces were intentionally deferred from v1 and are **native-only** today: ### 1. SSE streaming on wasm The generated `events()` / `subscribe_events_at()` and the per-method `x-sse` helpers (`*_events`, `follow_*_sse`, `collect_*_sse`) are `#[cfg(not(target_arch = "wasm32"))]`. The native path uses hyper/tokio SSE-over-UDS (`crates/openrpc/src/sse.rs`), which can't run in the browser. **Task:** add a browser SSE transport using `gloo-net`'s `EventSource` (feature `eventsource`), expose it on the wasm `OpenRpcTransport` as `sse_subscribe`, and drop the wasm gate on the generated SSE helpers so they emit on both targets. Keep `SseEvent` shared across targets. ### 2. Multi-domain bundle on wasm The directory-form bundle (`openrpc_client!("dir", service = "...")` → `HeroDemoClient` with `.dom1()/.dom2()`) connects over Unix sockets; its `connect()` is `#[cfg(not(target_arch = "wasm32"))]`. The inner per-domain clients already get a wasm `new(base_url)`. **Task:** add a wasm bundle `new(base_url)` that builds each domain client over HTTP, once the hero_router per-domain URL convention is confirmed (e.g. `{base_url}/<service>_<domain>/rpc` vs `{base_url}/<domain>/rpc`). ### Pointers - Transport: `crates/openrpc/src/transport/openrpc.rs` (native + wasm `OpenRpcTransport`) - Macro: `crates/derive/src/openrpc_client.rs` (`generate_client_code`, `generate_client_bundle`) - Deps: `crates/openrpc/Cargo.toml` (target-gated `gloo-net`)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_lib#147
No description provided.