feat(runtime): framing, transport, Client, Server - #7
Merged
Conversation
The second layer of @comline/runtime — the pieces a generated
<Proto>Client / dispatcher plug into:
- Framing interface + DatagramFraming (compact `[call_id:u16][request_id:u64]
[params]` request, `[request_id:u64][tag-byte envelope]` response) and
JsonRpcFraming (`{"jsonrpc":"2.0",...}`), both wire-compatible with
comline-runtime — the datagram header layout and the JSON-RPC frame
wording are byte-checked in the tests.
- envelope.ts — the `[0]payload` / `[1]id:u16 body` tag-byte form.
- Transport interface + duplex() — a connected in-memory pair; close()
ends a serve loop.
- Client — connect() runs the handshake; call() frames / sends / awaits /
returns the raw Envelope; notify() is fire-and-forget.
- Server — serve() / serveHandshaked(): decode request, resolve the call
against Dispatch.calls(), dispatch into a Reply, frame the response by
outcome (none -> silent, ok, err+ordinal).
Tests add a full hand-written Chat client ⇆ provider round-trip over
duplex() — request/response, a raised typed error, a one-way notify — run
against both framings, plus a handshake wire-format-mismatch rejection.
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.
The second layer of
@comline/runtime— what a generated<Proto>Client/ dispatcher will plug into.Framing+DatagramFraming[call_id:u16 LE][request_id:u64 LE][params], response[request_id:u64 LE][tag-byte envelope]— wire-compatible withcomline_runtime::contract::DatagramFraming(header layout byte-checked)JsonRpcFraming{"jsonrpc":"2.0","method":…,"params":…,"id":…}etc. — matchescomline_runtime::framing::JsonRpcFraming(frame wording byte-checked)envelope.ts[0]payload/[1]id:u16 bodytag-byte formTransport+duplex()close()ends a serve loopClientconnect()runs the handshake;call()frames/sends/awaits/returns the rawEnvelope;notify()fire-and-forgetServerserve()/serveHandshaked(): decode → resolve againstDispatch.calls()→ dispatch into aReply→ frame by outcome (none → silent, ok, err+ordinal)Tests: a full hand-written
Chatclient ⇆ provider round-trip overduplex()(request/response, a raised typed error, a one-way notify) run against both framings, plus a handshake wire-format-mismatch rejection. 19 tests,npm testgreen.Next: the generator emits
<Proto>Client/<Proto>Dispatcheragainst this package; thenlibmode (npm package output); then a stream transport + a MessagePack codec.