Add support for WireFormat + binaryBytes passthrough#133
Add support for WireFormat + binaryBytes passthrough#133ashkalor wants to merge 1 commit intocloudflare:mainfrom
Conversation
|
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
Hey any updates on this? @kentonv If this approach is against the vision of this library, I'd be happy to make necessary changes to accomodate the vision. Please let me know. |
|
Hi, sorry, this is in my inbox but it's a pretty busy inbox and I tend to handle the capnweb stuff in batches every couple weeks. Looking briefly, I wonder if a different design would work with less code needed: Instead of giving the system a Actually I could imagine we have multiple levels of encoding:
|
|
That makes a lot of sense, so basically you want this to be handled in the transport layer. Are you comfortable with me adding Generic type support to RPC transport? Something like below // Core types in src/serialize.ts:
export type EncodingLevel = "stringify" | "devalue" | "partial" | "passthrough";
export type TransportData<L extends EncodingLevel> = L extends "stringify" ? string : object;
// Generic RpcTransport in src/rpc.ts:
export interface RpcTransport<L extends EncodingLevel = "stringify"> {
readonly encodingLevel?: L;
send(message: TransportData<L>): Promise<void>;
receive(): Promise<TransportData<L>>;
abort?(reason: any): void;
}Where Also do you want me to close this pull request and create a new one for these changes? Or can I force push the new changes directly under the same branch? |
stringtostring | ArrayBufferMy main motivation was to be able to directly pass messages without having to message -> base64 -> stringify - > parse -> decode -> message.
If we use a package like CBOR, message -> encode -> decode (which is very fast) -> message, skipping the whole base64 encode and decode. This basically allows someone in the userland to define their own interface that works with RPC
I did some benchmarks for this
Wire Size
Performance
P.S: Huge fan of your work btw! Been following your work from capnproto days!