-
Notifications
You must be signed in to change notification settings - Fork 1
/
kvs_server.h
50 lines (46 loc) · 1.53 KB
/
kvs_server.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
46
47
48
49
50
#ifndef CHIRP_KVS_SERVER_H
#define CHIRP_KVS_SERVER_H
#include <mutex>
#include <string>
#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_backend.h"
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
using grpc::ServerReader;
using grpc::ServerReaderWriter;
using grpc::ServerWriter;
using grpc::Status;
using grpc::StatusCode;
using chirp::PutRequest;
using chirp::PutReply;
using chirp::GetRequest;
using chirp::GetReply;
using chirp::DeleteRequest;
using chirp::DeleteReply;
using chirp::KeyValueStore;
// KeyValueServer class supports takes request from
// KeyValueClient in Service Layer to support
// get, put, and delete requests on key value backend
class KeyValueServer final : public KeyValueStore::Service {
public:
// put key and value pair in `key_value_pairs_` data structure
Status put(ServerContext *context, const PutRequest *request,
PutReply *reply) override;
// get value based upon key string from `key_value_pairs_` member variable
Status get(ServerContext *context,
ServerReaderWriter<GetReply, GetRequest> *stream) override;
// delete key-value pair given key from `key_value_pairs_` variable
Status deletekey(ServerContext *context, const DeleteRequest *request,
DeleteReply *reply) override;
private:
// class that stores key value pairs as a map
KeyValueBackend kvs_backend_;
};
#endif // CHIRP_KVS_SERVER_H