-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cpp
27 lines (26 loc) · 823 Bytes
/
main.cpp
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
#include <iostream>
#include <grpcpp/grpcpp.h>
#include "proto/gerdu.grpc.pb.h"
using namespace gerdu;
using namespace std;
using namespace grpc;
int main() {
const char *target = "localhost:8081";
auto channel = CreateChannel(
target, InsecureChannelCredentials());
unique_ptr<Gerdu::Stub> stub(Gerdu::NewStub(channel));
PutRequest putRequest;
putRequest.set_key("Hello");
putRequest.set_value("World");
PutResponse putResponse;
ClientContext context1;
stub->Put(&context1, putRequest, &putResponse);
// putResponse.created == 1
GetRequest getRequest;
getRequest.set_key("Hello");
GetResponse getResponse;
ClientContext context2;
stub->Get(&context2, getRequest, &getResponse);
cout << "Hello = " << getResponse.value() << endl;
return 0;
}