Waiting with a timeout

Skip to first unread message

Björn Schäpers

Jun 7, 2021, 10:08:08 PMJun 7
to capn...@googlegroups.com
Hi there,

I've started using Cap'n Proto RPC. Until now I only have some tests to ensure
Cap'n Proto behaves as expected for me.

What is missing for me is waiting with a timeout, or I don't see it. I want to
be able to shut the server down, and NEVER_DONE seems not right for that. In my
tests I'm using poll with a sleep in a loop.

Currently I'm using the Ez RPC, and to be honest the RPC System and associates
are a bit overwhelming without documentation or good examples.

Kind regards,

Kenton Varda

Jun 7, 2021, 10:38:46 PMJun 7
to Björn Schäpers, Cap'n Proto
Hi Björn,

Instead of Ez RPC, try using kj::setupAsyncIo() and capnp::TwoPartyClient / capnp::TwoPartyServer. These APIs give you more control. In particular, kj::setupAsyncIo() returns an kj::AsyncIoProvider which, among other things, provides a kj::Timer API which you can use for timeouts.

KJ's and Cap'n Proto's header files are well-commented. We consider the header comments to be the API reference documentation.


You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/d4160a10-c30c-d209-c12f-70b550e5ce0a%40hazardy.de.

Björn Schäpers

Jun 8, 2021, 2:25:53 PMJun 8
to Kenton Varda, Cap'n Proto
Thanks, I will look into that.

Yes I know the code is documented, without that I wouldn't have come this far.
But what is missing, at least for me, is the bigger picture, i.e. how to combine
all these rpc related classes, and what I need to implement and what not.

If I use the setupAsyncIo and TwoPartyServer, do I need to use the
TwoPartyClient, or can that stay an EzClient?

> <mailto:capnproto%2Bunsu...@googlegroups.com>.

Kenton Varda

Jun 9, 2021, 12:25:46 PMJun 9
to Björn Schäpers, Cap'n Proto
Yes, I agree there's some missing overview docs regarding Cap'n Proto RPC. The web page is not very detailed.

FWIW, I recently wrote an overview/tour of KJ: https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md

But that doesn't cover Cap'n Proto itself.

> If I use the setupAsyncIo and TwoPartyServer, do I need to use the
> TwoPartyClient, or can that stay an EzClient?

The protocols are the same, so you could use EzClient on the client side and TwoPartyServer on the server. However, I would recommend avoiding the EZ interfaces entirely. Over time I've come to regret having created them, as they are too inflexible for many use cases.

Reply all
Reply to author
0 new messages