Commit Graph

28 Commits

Author SHA1 Message Date
Asias He
624388ae4b rpc: Move stats to rpc_types.hh
It will be needed by user does not want to include rpc.hh
2015-07-16 14:55:51 +08:00
Asias He
6ad04ff5e8 rpc: Introduce rpc/rpc_types.hh
Include rpc_types.hh instead of rpc.hh when no_wait_type and friends are
needed.
2015-07-16 14:55:50 +08:00
Gleb Natapov
3dbccbc5b5 rpc: read value from a tuple before moving it
Noticed by Tomek.
2015-07-07 13:21:11 +03:00
Avi Kivity
0c848e9a4e rpc: add missing move()s in get_reply()
If the reply is a movable-but-not-copyable type, then we must move it into
the returned future.  Also faster even if the type is copyable.
2015-07-07 12:56:33 +03:00
Gleb Natapov
d0003e4f29 rpc: handler smart pointer return value from rpc handler
Currently if rpc handler returns smart pointer rpc will try to serialize
the pointer object as opposite to an object the ptr is pointing to.
This patch fixes it by serializing real object instead of a pointer.
2015-07-02 16:46:23 +03:00
Gleb Natapov
46f47b7ea2 rpc: implement stop for server/client connection 2015-06-18 14:43:16 +03:00
Amnon Heiman
bb4b15566c rpc: fix get_stats not returning the updated stats structure
get_stats needs to return the copy of the stats structure. Not the
original value.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-05-27 15:06:01 +03:00
Gleb Natapov
cb6361ed03 rpc: add ability to bind client to a specified local address 2015-05-20 17:10:00 +03:00
Amnon Heiman
03c4a6d050 rpc: add counters to the rpc client
This adds a counters to net protocol client.
The client would holds counter for the successfully completed, the
exception recieved and as the sent queue is based on the future queue
a counter for pending to sent messages.

The number of messages that waiting for reply is retrieved from the size
of the outstanding table.

The counters are updated by the helper send function as part of the
messages sending flow.

The counters are part of the stat structure and the client has an
internal getter to be able to change their values and a getter that
returns a copy of the counters.
2015-05-18 15:26:46 +03:00
Gleb Natapov
3188ae6b8b rpc: remove unneeded capture
Also 'sent' is moved twice. I wonder how it even worked. Second move was
probably done first.
2015-05-11 10:49:11 +03:00
Gleb Natapov
c18e76cb10 rpc: fix out stream flushing
Flush it only once per rpc call instead of once per argument.
2015-05-07 13:29:34 +03:00
Gleb Natapov
de2e297016 rpc: handle future<> return type of an rpc handler properly 2015-05-05 12:08:06 +03:00
Gleb Natapov
2ec7535969 rpc: allow handler to receive non default constructable types
Currently it is not possible because a type is instantiated before been
deserialized. Fix that by allocating space for an object by using
std::aligned_storage.
2015-05-03 19:02:33 +03:00
Gleb Natapov
dfa0f1c003 rcp: put client into an error state when connection is broken 2015-04-30 12:27:57 +03:00
Gleb Natapov
0a47b5f7c9 rpc: return exception as a future instead of throwing in client send path
This simplifies error handling in a client code since it needs to only
check future for an exception and do not put 'try' block around a call
itself.
2015-04-30 12:27:56 +03:00
Gleb Natapov
2e54725017 rpc: allow handler to return a type without default constructor
Currently it is not possible because a type is instantiated before been
deserialized. Fix that by allocating space for an object by using
std::aligned_storage.
2015-04-29 18:58:07 +03:00
Gleb Natapov
3f3987e7ab rpc: handle exception during unmarshalling
Unmarshalling function should not throw, but in case it does move
connection to an error state and report the error to an rpc client.
Currently all errors are reported as rpc::closed_error().
2015-04-27 11:21:54 +03:00
Gleb Natapov
8825b96a44 rpc: add virtual destructor for reply_handler
Without virtual destructor handler's memory is leaking.
2015-04-27 11:21:53 +03:00
Gleb Natapov
349f21c860 rpc: signal send completion even if send failed due to a socket error
When call to marshall fails with an exception the exception future is
stored in dst.out_ready(). During next send sent future will not be
signaled because marshall() will never be called. Fix that by moving
sent future signaling to consider dst.out_ready() state too.
2015-04-22 13:00:58 +03:00
Asias He
9dff2bfa40 rpc: Fix indentation
Signed-off-by: Asias He <asias@cloudius-systems.com>
2015-04-08 17:10:53 +03:00
Asias He
60ece9f40d rpc: Do not initialize MsgType _type
Fix compiling issue when using rpc with MsgType other than int.

Signed-off-by: Asias He <asias@cloudius-systems.com>
2015-04-08 17:10:52 +03:00
Gleb Natapov
dbe2443c03 rpc: wait for message to be send in rpc::no_wait client's handlers
rpc::no_wait is too "no_wait" currently. When client sends a no_wait
message it immediately gets ready future in return, so client cannot
know when data is actually sent and can be discarded. This patch fixes
this by returning a future that will become ready when data is no longer
needed.
2015-04-01 14:55:58 +03:00
Gleb Natapov
5558abe9ec rpc: drop unused template parameter 2015-03-31 16:45:20 +03:00
Gleb Natapov
937970ccd3 rpc: keep shared pointer to a client connection
Client connection may outlive its do_until() loop. Make connection
point shared to overcome this. If connection dies while async handler
is running it will not be deleted until the handler is executed.
2015-03-25 11:32:33 +02:00
Gleb Natapov
9f0900ee0f rpc: add logger and log exception in no_wait callback 2015-03-22 16:16:23 +02:00
Gleb Natapov
12885b924c rpc: add a possibly to pass client_info to an rpc handler
If rpc handler needs locally held information about rpc client that
making a call it may have client_info as a first parameter of rpc
handler. Rpc framework will pass it to the callback during invocation.
2015-03-22 16:16:17 +02:00
Gleb Natapov
7fe06f006e rpc: introduce rpc::no_wait
If registered callback returns rpc::no_wait a client will not wait
for remote function execution and will get immediately ready future.
2015-03-22 16:16:09 +02:00
Gleb Natapov
36b76af7cc Implementation of rpc
To register rpc handler func(param1, param2, param3) both server and client

auto remote_func = myrpc.register_handler(id, func);

This call will return another function that client can use to invoke RPC
calls like this:

remote_func(client, param1, param2, param3);

This call will return future<> with func() result.
2015-03-12 15:38:18 +02:00