google / tarpc

An RPC framework for Rust with a focus on ease of use.
MIT License
3.18k stars 194 forks source link

Json support and automatic documentation generation #442

Open pmantica11 opened 7 months ago

pmantica11 commented 7 months ago

Thank you for this amazing project!

I have two questions:

  1. Does it support jsonrpc?
  2. Does it support automatic SDK generation for the API?
tikue commented 6 months ago

Hi, thanks!

  1. Reading the spec, it sounds like jsonrpc is a transport-agnostic, stateless RPC protocol. tarpc is also transport-agnostic, so I kind of imagine that a jsonrpc library would be filling a similar niche to tarpc. But if there is a specific crate you are interested in using, share the link and I'll take a look!
  2. If you run cargo doc on your crate, it should generate documentation for the generated types. Is that what you're looking for? Let me know if something appears to be missing. The readme mentions this, but feel free to send a PR if it's not clear enough.
dan-da commented 6 months ago

I'm also interested in a tarpc jsonrpc transport.

As I understand it, jsonrpc is transport-agnostic in the sense that it can be used over eg unix sockets, tcp, udp, http, etc. But not in the sense that one can change the serialization format (json) or method invocation and response envelopes.

Clearly json is compatible with tarpc. The question in my mind is if/how the request/response mechanism could be integrated. So a json-rpc method-call would be routed to a tarpc server trait method, and also if a method returns an error then it should be converted into a jsonrpc error.

I'm hopeful that this kind of translation could occur in a hypothetical tarpc-jsonrpc-transport crate, but I am not familiar enough with tarpc's transport plugin layer to understand how methods are invoked exactly.

@tikue does the above seem achievable to you?