mirror of
https://github.com/zap-proto/js.git
synced 2026-10-30 15:04:48 +00:00
pipeline.ts claimed to mirror "the canonical Go ZAP client's Pipeline()" —
a function that did not exist — and carried a TODO for the single-connection
variant. Now that Go has a real Target model (rpc.Session/rpc.Pipeliner),
make the TS runtime its true byte-for-byte peer and tell the truth.
New src/promise.ts (universal, no node:net — exported from the root):
- Session: PromiseID allocator + origin/pipe Call builders (peer of
rpc.Session; sequence starts at 1 to match Go).
- Pipeliner: server-side promise table over a dispatch fn — resolve Target
before dispatch, queue an unresolved dependent until it resolves, refuse
(StatusBadRequest, no hang) a failed/finished target. finish() bounds it.
src/pipeline.ts is now ONLY the two-connection socket overlap on top of
promise.ts, with an honest doc: the MECHANISM is the Target field resolved
by a Pipeliner (the unit-tested in-process path); two connections exist only
because one ZAP connection is strictly FIFO. No false "mirrors Pipeline()",
no TODO.
zapgen (src/zapgen/emit.ts): the generated TS client now mirrors the Go one
exactly — a Session field, m() (originating) + mOn(on) (pipelined) through a
shared invoke<M>. Dropped the hardcoded `target: NO_TARGET` / `promiseID: 0`.
Tests: test/pipeline.test.ts drives the REAL Target field end-to-end
(resolution, queuing, 3-deep chain, failure propagation, finish, byte-level
wire encoding) — not a typeof check. zapgen.test asserts the canonical
pipelining client is emitted. 119 tests green; root stays browser-safe.