-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey_store_client.h
More file actions
54 lines (41 loc) · 1.45 KB
/
key_store_client.h
File metadata and controls
54 lines (41 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "commons.h"
#include "key_store_services.grpc.pb.h"
#include "client.h"
using grpc::Channel;
using grpc::ClientContext;
using grpc::ClientReader;
using grpc::ClientReaderWriter;
using grpc::ClientWriter;
using grpc::Status;
using KeyStore::KeyStoreRequest;
using KeyStore::KeyStoreResponse;
using KeyStore::KeyStoreService;
/* Indvidual client */
class key_store_client
{
private:
public:
std::unique_ptr<KeyStoreService::Stub> stub_;
key_store_client(std::shared_ptr<Channel> channel): stub_(KeyStoreService::NewStub(channel)){};
};
/* This funciton sends message to each server */
//void send_to_server_handler(key_store_client* connection_stub,
// promise<request_t*>& ketStoreResponsePromise, KeyStoreRequest *req);
/*https://stackoverflow.com/questions/10890653/why-would-i-ever-use-push-back-instead-of-emplace-back/10890716
emplace_back is used when we have to call explicit constructor, since this object dont have one, hence not using it */
class server_connections {
/* Each client will have connection with server
we done need to create connection everytime
*/
public:
map<string, key_store_client*> connections;
server_connections(struct Server_info* servers, uint32_t number_of_servers);
~server_connections();
};
/*i = Internal*/
typedef struct client_wrapper_i {
Client *cl;
server_connections *conn;
} client_wrapper;
mutex client_list_mutex;
std::map<uint32_t, client_wrapper*> client_list;