MatrixAI / js-rpc

Stream-based JSON RPC for JavaScript/TypeScript Applications

Home Page:https://polykey.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IdGen function should work per call.

addievo opened this issue · comments

Refactor IdGen to assign IDs on a per-call basis for streamed RPC responses, ensuring that all responses in a stream share the same ID as the originating request.

Description

In the existing setup, IdGen assigns unique IDs to each individual RPC request. This becomes problematic when streaming multiple responses, as each response should have an ID identical to that of the original request, according to the JSON RPC Spec.

Tasks

  • 1. Refactor IdGen so that it applies ID on a per-call basis.

Draw up the unary, client streaming, server streaming, duplex streaming examples as I had on the whiteboard.

I had a thought that ID gen could also generate subids for each serial message in a call. But that would be something for the future.

If you want to avoid using fix in the commit message I suggest formatting it like this.

fix: fixes problem with id generation

* Related: #11

[ci skip]