Skip to content

feat: consumer-side Client + a TCP transport (rollout step 7e) - #5

Merged
Kinflou merged 1 commit into
mainfrom
feat/runtime-client
Sep 1, 2026
Merged

feat: consumer-side Client + a TCP transport (rollout step 7e)#5
Kinflou merged 1 commit into
mainfrom
feat/runtime-client

Conversation

@Kinflou

@Kinflou Kinflou commented Sep 1, 2026

Copy link
Copy Markdown
Member

Follows #4 — the mirror of 7d's Server, and a real stream transport under it.

module
client Client<T, W> — owns a Transport + a WireFormat, hands out request ids, reuses its send / recv buffers. call(call_id, &params) frames the header, serializes params straight in after it (no scratch buffer), sends, blocks for the response, and returns (Envelope<'_>, &W) — both views out of one &mut self borrow, so the generated stub decodes Ok as R or maps an Err ordinal without reaching back into the client. One outstanding call at a time; pipelining is a later, additive layer.
transport Tcp — a Transport over a TCP byte stream. A stream has no message boundaries, so every frame gets a u32 LE length prefix; recv reads exactly one and rejects a prefix over MAX_FRAME (16 MiB) before allocating. Tcp::new wraps an accepted stream, Tcp::connect dials.
wire encode_request_header split out of encode_request so a client can frame the header then encode params into the same buffer.

tests/client_roundtrip.rs — a Greet protocol (with a raised schema error) driven through a Client-backed stub against a Server, once over InMemory and once over loopback Tcp, plus a check that back-to-back Tcp frames keep their boundaries.

Client is alloc-gated (Vec buffers) like serve / transport; Tcp is std-gated like InMemory.

Verified

All feature configs green: cargo test (13 lib + 3 client + 3 dispatch + 1 serve), --no-default-features (2), --features alloc (9). Warnings unchanged (1 — the pre-existing abi_stable macro lint).

Next (7f)

Fold JSON-RPC back in as a framing option (name-oriented Kind, {jsonrpc, method, params, id} envelope) selectable under the same Client / Server; then the async (std) layer.

The mirror of 7d's Server, and a real stream transport under it.

- client     Client<T, W> -- owns a Transport + a WireFormat, hands out
             request ids, reuses its send / recv buffers. call(call_id,
             &params) encodes straight into the frame header (no params
             scratch), sends, blocks for the response, and returns
             (Envelope, &W) -- both views out of one &mut self borrow, so the
             generated stub can decode Ok as R or map an Err ordinal without
             reaching back into the client. One outstanding call at a time;
             pipelining is a later, additive layer.
- transport  Tcp -- a Transport over a TCP byte stream. No message
             boundaries on a stream, so each frame gets a u32 LE length
             prefix; recv reads exactly one and rejects a prefix over
             MAX_FRAME (16 MiB) before allocating. new() wraps an accepted
             stream, connect() dials.
- wire       encode_request_header split out of encode_request, so a client
             frames the header then serializes params into the same buffer.

tests/client_roundtrip.rs: a Greet protocol (with a raised schema error)
driven through a Client-backed stub against a Server -- once over InMemory,
once over loopback Tcp -- plus a check that back-to-back Tcp frames keep
their boundaries.

Client is alloc-gated (Vec buffers), like serve / transport; Tcp is
std-gated, like InMemory. All feature configs green: cargo test (13 lib + 3
client + 3 dispatch + 1 serve), --no-default-features (2), --features alloc
(9). Warnings unchanged (1, the pre-existing abi_stable macro lint).
@Kinflou
Kinflou merged commit 93af95d into main Sep 1, 2026
6 checks passed
@Kinflou
Kinflou deleted the feat/runtime-client branch September 1, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant