More thrift scaffolding

This commit is contained in:
Tyler Neely 2022-08-11 16:56:53 +00:00
parent f98f4d6841
commit d05d649924

View File

@ -19,21 +19,25 @@ namespace memgraph::io::thrift {
using memgraph::io::Address;
using memgraph::io::OpaqueMessage;
using memgraph::io::OpaquePromise;
using RequestId = uint64_t;
class ThriftHandle {
mutable std::mutex mu_{};
mutable std::condition_variable cv_;
// the responses to requests that are being waited on
std::map<PromiseKey, DeadlineAndOpaquePromise> promises_;
std::map<RequestId, DeadlineAndOpaquePromise> promises_;
// messages that are sent to servers that may later receive them
std::map<Address, std::vector<OpaqueMessage>> can_receive_;
std::vector<OpaqueMessage> can_receive_;
// TODO(tyler) thrift clients for each outbound address combination
std::map<Address, void> clients_;
public:
template <Message Request, Message Response>
void SubmitRequest(Address to_address, Address from_address, uint64_t request_id, Request &&request, Duration timeout,
ResponsePromise<Response> &&promise) {
void SubmitRequest(Address to_address, Address from_address, RequestId request_id, Request &&request,
Duration timeout, ResponsePromise<Response> &&promise) {
// TODO(tyler) simular to simulator transport, add the promise to the promises_ map
Send(to_address, from_address, request_id, request);
@ -45,7 +49,7 @@ class ThriftHandle {
}
template <Message M>
void Send(Address to_address, Address from_address, uint64_t request_id, M message) {
void Send(Address to_address, Address from_address, RequestId request_id, M message) {
// TODO(tyler) call thrift client for address (or create one if it doesn't exist yet)
}
};