Repository navigation
feat(relay): embed the relay-tunnel receiver behind a tunnel feature (WIP) - #94
Draft
slinkydeveloper wants to merge 1 commit into
Draft
slinkydeveloper wants to merge 1 commit into
slinkydeveloper wants to merge 1 commit into
Conversation
Bring the SDK-side relay stack into shared-core so SDKs can act as relay
receivers without reimplementing the protocol, and without the relay runtime
owning the SDK's threads. Everything lives under `src/relay/` gated by
`#[cfg(feature = "tunnel")]` (off by default), so the crate stays strictly
sans-IO and WASM-compilable when the feature is off.
Contents (a fork of the relay repo's crates + a new engine):
* protocol/ — was relay-protocol: env/tunnel, path grammar, /whoami, h2
tuning. Sans-IO. Internal `crate::` refs rewritten to `super::`.
* bridge.rs — was relay-bridge: the bidirectional h2 bridge (failpoints
hooks stripped; shared-core has no `failpoints` feature).
* receiver/ — was relay-receiver: dial-out, role-flip, /whoami, redial,
multi-homing (R4) + instance-id affinity (R5), InvokeHandler.
* loopback.rs — new: the engine. Owns a tokio runtime, runs the receiver with
a LoopbackHandler that h2c-dials 127.0.0.1:<local_port> and
bridges each forwarded stream, replaying the tail-only `:path`
(preserves request-identity) + headers verbatim. JSON `Config`
(serde), `Engine::start` -> `Handle` (status/stop), `Status`.
The `tunnel` feature pulls in optional tokio/h2/http/tokio-rustls/
rustls-pki-types/async-trait/serde_json. `http` is now an explicit feature
(`dep:http` elsewhere would otherwise suppress its implicit feature and break
`#[cfg(feature = "http")]` in headers.rs + any external `features=["http"]`).
Verified: default `cargo tree` has no tokio (sans-IO preserved); default tests
green; `--features tunnel` builds, `tests/relay_loopback.rs` round-trips a
forwarded request end-to-end; clippy `-D warnings`, rustfmt, and rustdoc all
clean on both feature sets.
No cross-repo coupling: the relay repo keeps its own copies untouched (forked
at move time). Design + rationale in docs/relay-receiver-in-shared-core.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Aug 12, 2026
Draft
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Bring the SDK-side relay stack into shared-core so SDKs can act as relay receivers without reimplementing the protocol, and without the relay runtime owning the SDK's threads. Everything lives under
src/relay/behind#[cfg(feature = "tunnel")](off by default), so the crate stays strictly sans-IO and WASM-compilable when the feature is off.protocol/— fork ofrelay-protocol(env/tunnel, path grammar,/whoami, h2 tuning). Sans-IO.bridge.rs— fork ofrelay-bridge(the bidirectional h2 bridge; failpoints hooks stripped).receiver/— fork ofrelay-receiver(dial-out, role-flip,/whoami, redial, multi-homing R4 + instance-id affinity R5,InvokeHandler).loopback.rs— new engine: owns a tokio runtime, runs the receiver with aLoopbackHandlerthat h2c-dials127.0.0.1:<local_port>and bridges each forwarded stream, replaying the tail-only:path(preserves request-identity) + headers verbatim. Public APIrelay::{Config, Engine, Handle, Status}(Configis serde-JSON).The
tunnelfeature pulls in optionaltokio/h2/http/tokio-rustls/rustls-pki-types/async-trait/serde_json.httpis now an explicit feature (adep:httpreference elsewhere would otherwise suppress its implicit feature and break#[cfg(feature = "http")]+ externalfeatures=["http"]).No cross-repo coupling
The three crates are copied in (forked), not shared with
restatedev/relay— that repo keeps its own copies untouched. Independence over DRY, on purpose. Seedocs/relay-receiver-in-shared-core.md.Verification
cargo treehas no tokio — the sans-IO / WASM invariant holds.--features tunnelgreen +tests/relay_loopback.rsround-trips a forwarded request end-to-end (relay → engine → loopback → local h2c server → back, query preserved).-D warnings, rustfmt, rustdoc all clean on both feature sets.Not in this PR
Live run against a real relay; TS/napi binding. v1 scope:
/whoamimode, loopback TCP, no drain.🤖 Generated with Claude Code