-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkvs_client.h
45 lines (41 loc) · 1.31 KB
/
kvs_client.h
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
#include <string>
#include <thread>
#include <iostream>
#include <memory>
#include <stack>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <grpcpp/grpcpp.h>
#include "KeyValueStore.grpc.pb.h"
#include "kvs_client_interface.h"
using grpc::Channel;
using grpc::ClientContext;
using grpc::ClientReaderWriter;
using grpc::Status;
using chirp::PutRequest;
using chirp::PutReply;
using chirp::GetRequest;
using chirp::GetReply;
using chirp::DeleteRequest;
using chirp::DeleteReply;
using chirp::KeyValueStore;
#ifndef CHIRP_KVS_CLIENT_H
#define CHIRP_KVS_CLIENT_H
// allows service layer to submit requests to
// the key-value store server over gRPC
class KeyValueClient : public KeyValueClientInterface {
public:
// construct client with channel to KeyValueServer class
KeyValueClient(std::shared_ptr<Channel> channel);
// take `key` and `value` to insert into key-value table
// and return whether insertion was successful
bool put(const std::string &key, const std::string &value);
// use `key` to return associated values
std::string get(const std::string &key);
// delete key value pair associate with `key` parameter
bool deletekey(const std::string &key);
private:
//`stub_` to send and receive data over gRPC
std::unique_ptr<KeyValueStore::Stub> stub_;
};
#endif // CHIRP_KVS_CLIENT_H