tyfon icon indicating copy to clipboard operation
tyfon copied to clipboard

Allow passing streaming primitives for streaming support

Open loreanvictor opened this issue 4 years ago • 0 comments

It would be really cool if we could do over-network streaming without any network programming. TyFON could provide that by allowing passage of callbags in parameters / return values (either directly or by embedding them inside other objects).

Implementation Proposal

  • Maintain a registry of IDd callbags on client and server.
  • During JSON serialization (on either side), handle callbags by giving them IDs if they don't, and return a special value that the recipient will know relates to a callbag, with the callbag's ID
  • During parsing the JSON, create proxy callbags with specified IDs and return them
  • When there is more than one callbag in client/server registry, ensure the client/server have a streaming channel open (for example, web sockets)
  • Originator proxies might also be needed, to serialize and pass messages around.
  • Termination signals should lead to clean-up of proxies on both sides.

Note that a callbag on originator side might have multiple proxies (as it is bound to multiple streaming channels). If implemented correctly, such a callbag should get cleaned up when it does not have any more subscribers.

Why Callbags?

I would love to support RxJS as well, but bi-directional message passing is much more clear with callbags. Additionally, callbags is merely a specification, which means this functionality can be added to tyfon-server and tyfon-client with zero additional overhead (which is important for client-side code). Since convenient converters exist, I doubt this will be an issue.

loreanvictor avatar Feb 07 '21 16:02 loreanvictor