-
Notifications
You must be signed in to change notification settings - Fork 197
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
Async via MIO. #37
Async via MIO. #37
Conversation
…tten. Also, don't remove writable() from EventSet unless there really is nothing left to write.
Making the client type-agnostic enables the Dispatcher to more easily group together multiple clients. It should be relatively easy to build a type-safe abstraction on top of them.
By moving type params from ClientHandle struct => ClientHandle::rpc method.
So that it can be used by both client and server.
… can't be modified.
Almost always, I prefer early returns. But in this case I think it's cleaner this way. I don't really know why.
Strangely, 2^18 is quite a bit faster than 2^17.
So that it can compile on windows.
The first 16 bytes are the id and len.
This allows us to cut down reading from 3 states to two states, because the id and message can be read together.
"RPC" stands for "Remote Procedure Call," a function call where the work of | ||
producing the return value is being done somewhere else. When an rpc function is | ||
invoked, behind the scenes the function contacts some other process somewhere | ||
and asks them to compute the function instead. The original function then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: s/compute/evaluate
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
I authored these commits |
Closing in favor of #44 |
Noteworthy bits:
Stream
andListener
.Client
which is callback based,BlockingClient
, andFutureClient
.BlockingServer
which spawns a thread per rpc, andServer
which is nonblocking.*client_methods!
macros by ditching theReply
enum. It wasn't required by the protocol since the client always knows what type to expect. We've discussed changing this in the future to return a standardprotocol::Reply
enum, which covers cases likeUnexpectedRequest
(if it couldn't be deserialized...etc.).Other changes
RpcError
andRpcErrorCode
.BlockingService
trait to have return types ofResult<T, tarpc::RpcError>
Ctx
et al to accept a return value ofResult<T, Into<tarpc::RpcError>>
.tarpc::Error
and it will convert it for you.RpcError
variant oftarpc::Error
. tarpc uses this to transformtarpc::RpcError
intotarpc::Error
behind the scenes for the client, to un-nest the result return type so that it isn'ttarpc::Result<tarpc::RpcResult<T>>
.RpcError
s with error codeWrongService
.shutdown
methods on the client and server handles. Event loops now can only be shutdown through the registries.Server::spawn
=>Server::listen
because it doesn't spawn a thread, and generally has a very small resource footprint.Client::spawn
=>Client::connect
for similar reasons.Client
=>AsyncClient
BlockingClient
=>SyncClient
Server
=>AsyncServer
BlockingServer
=>SyncServer
Debug
variant to client and serverDispatcher
Action
s andfn debug
to the registries. This makes it easy to get information about the running dispatchers. Currently only returns the number of handlers running.fn
sconnect
andregister
into the traitprotocol::client::Client
. This prevents name collisions with rpcs.fn
slisten
andregister
into a traitServiceExt
that's expanded by theservice!
macro, for the same reason as the previous bullet.__AsyncServer
intofn register
ofServiceExt
to prevent unlikely collisions.Ctx
andSendCtx
out of the macro and intoprotocol::server
. Instead the macrocreates a
Ctx
extension trait thatprotocol::server::Ctx/SendCtx
impl
.Ctx::rpc
finisher methods with a singleCtx::reply
method, and madeCtx
genericover the reply type, i.e. the ctx arg type to the service fns is now
Ctx<Reply>
.CachedPool
for use bySyncService
. It is a growable thread pool whose idle threads expire on a configurable timer.Closes #38