-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple blocking (non-async) RPC example over unix domain sockets #232
Comments
Thanks for the feedback! I am well aware that the capnp-rpc has a lot of rough edges, and it does help to hear about your specific experiences.
I don't see anything obviously wrong with your example code. I agree that it's annoying that you need to
On a client, if all of the calls have completed, there's no harm in dropping the
What would your idiomatic version look like in the case where the method's return type a struct? struct CountContext {
name @0 : String;
...
}
interface Counter {
count @0 () -> (count :UInt64, context: CountContext);
} To make this feel like idiomatic Rust, I think we would need to figure out an automatic mapping between capnp types and Rust-native types. That would be very cool to have, but it would take a lot of work. |
Great, thanks so much for looking over it.
It would definitely be possible to spawn a task, but I was trying to stay as far away from async as possible, ideally so that when any of the library functions return nothing else is left running, hence looking for the simplest possible blocking executor. Perhaps this isn't a sensible goal, but it was a goal I had in mind.
Thanks, good to know. It would be great if this were added to doc comments
Yeah, I guess this is where the work would balloon somewhat. My first thought would be to generate rust |
See #157 for some work in this direction. |
I was just thinking about whether it would be possible to use Cap'n Proto RPC in a non-async application (in particular, I was interested in using unix domain sockets as transport). I've thrown together a simple example which I'd love to get your thoughts on: gist.
Observations:
VatNetwork
isAsyncRead
andAsyncWrite
objects, made the socket stuff surprisingly easy.RpcSystem
on the client side. I get the generatedClient
struct contains some handle back to theRpcSystem
so it can pass requests to it/receive responses from it. However, it would have been amazing to be able to get a future fromRpcSystem
which is "run until you've nothing to do", so I don't have toselect
with thepromise
.capnp_rpc
is surprisingly heavy in binary-size (4.5% 28.0% 209.5KiB capnp_rpc
fromcargo-bloat
for theserver
, for example), not problematically huge, just a little surprising.lib.rs
itself:5.0% 30.8% 233.9KiB cprpc_blocking
RpcSystem
actually do when polled? what does it mean to "bootstrap" it?). Generally, I find the API and naming very confusing (though I get that some of this is inherited from the upstream project). This is especially fraught because so much of the machinery is generated from the schema file.Specific questions:
async_io
for theAsync
trait anyways).RpcSystem
s nicely?Finally (and this may be better for a different issue), I don't understand why there isn't an option to generate a more idiomatic version of the
Server
trait? Is it just that it would be too much work? I'm thinking something that would look likerather than messing around with
Params
andResults
objects. My guess is that the answer is "you'd just be hiding the boilerplate and potentially doing unnecessary work", but surely it's much more common to want access to all params and results?The text was updated successfully, but these errors were encountered: