Commit d35cdcfb authored by ritapravo's avatar ritapravo

added

parent 7c7ebadd
File added
Team Members
Ashwin Patidar 213050063
Debajyoti Saha 21Q050001
Ritapravo Sarkar 213059003
Prerequisite:--
Installation of grpc in the system.
1. To build Server and Client:
Put "assignment4" directory (available in submission) in grpc/examples/cpp/ folder and run this commands
$ cd assignment4
$ mkdir -p cmake/build
$ pushd cmake/build
$ cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
$ make
now to run server and client you have to be in assignmnet4/cmake/build directory and run this commands their
1. for server in one terminal
$./server
2. for client in other terminal
$./client
References :
1. for LFU cache :- https://www.youtube.com/watch?v=rSwmpWaJPG0&ab_channel=TechLifeWithShivank
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
KeyValueStore
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/assignment4.iml" filepath="$PROJECT_DIR$/.idea/assignment4.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
# Copyright 2020 the gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
licenses(["notice"]) # 3-clause BSD
cc_binary(
name = "keyvaluestore_client",
srcs = [
"caching_interceptor.h",
"client.cc",
],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//examples/protos:keyvaluestore",
],
)
cc_binary(
name = "keyvaluestore_server",
srcs = ["server.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//examples/protos:keyvaluestore",
],
)
# Copyright 2021 the gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# cmake build file for C++ keyvaluestore example.
# Assumes protobuf and gRPC have been installed using cmake.
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building keyvaluestore.
cmake_minimum_required(VERSION 3.5.1)
project(KeyValueStore C CXX)
include(../cmake/common.cmake)
# Proto file
get_filename_component(kvs_proto "keyvaluestore.proto" ABSOLUTE)
get_filename_component(kvs_proto_path "${kvs_proto}" PATH)
# Generated sources
set(kvs_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/keyvaluestore.pb.cc")
set(kvs_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/keyvaluestore.pb.h")
set(kvs_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/keyvaluestore.grpc.pb.cc")
set(kvs_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/keyvaluestore.grpc.pb.h")
add_custom_command(
OUTPUT "${kvs_proto_srcs}" "${kvs_proto_hdrs}" "${kvs_grpc_srcs}" "${kvs_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${kvs_proto_path}"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${kvs_proto}"
DEPENDS "${kvs_proto}")
# Include generated *.pb.h files
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
# kvs_grpc_proto
add_library(kvs_grpc_proto
${kvs_grpc_srcs}
${kvs_grpc_hdrs}
${kvs_proto_srcs}
${kvs_proto_hdrs})
target_link_libraries(kvs_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
# client
add_executable(client "keyvalueclient.cc")
target_link_libraries(client
kvs_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
# server
add_executable(server "keyvalueserver.cc")
target_link_libraries(server
kvs_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
#include<bits/stdc++.h>
#include "KVFiles.cpp"
#include "pthread.h"
using namespace std;
void remove(string t, queue<string>& q)
{
queue<string> ref;
int s = q.size();
int cnt = 0;
while (q.front() != t and !q.empty()) {
ref.push(q.front());
q.pop();
cnt++;
}
if (q.empty()) {
cout << "Element not found in Cache!!" << endl;
while (!ref.empty()) {
q.push(ref.front());
ref.pop();
}
}
else {
q.pop();
while (!ref.empty()) {
q.push(ref.front());
ref.pop();
}
int k = s - cnt - 1;
while (k--) {
string p = q.front();
q.pop();
q.push(p);
}
}
}
pthread_mutex_t l;
class LRUCache {
private:
unordered_map<string,string> mp;
queue<string> q;
int len;
public:
LRUCache(int capacity) {
len=capacity;
pthread_mutex_init(&l,NULL);
}
string get(string key) {
pthread_mutex_lock(&l);
auto it=mp.find(key);
if(it==mp.end())
{
string v = getFromFile(key);
if(!v.compare("0")) {
pthread_mutex_unlock(&l);
return "key not found";
}
else{
add(key,v);
pthread_mutex_unlock(&l);
return v;
}
}
remove(key, q);
q.push(key);
pthread_mutex_unlock(&l);
return it->second;
}
void add(string key,string value){
auto it=mp.find(key);
if(it!=mp.end()) {
it->second=value;
remove(key, q);
q.push(key);
return;
}
else
{
if(mp.size()<len) {
mp[key]=value;
q.push(key);
return;
}
else
{
string cur=q.front();
q.pop();
mp.erase(cur);
mp[key]=value;
q.push(key);
return;
}
}
}
void put(string key, string value) {
pthread_mutex_lock(&l);
auto it=mp.find(key);
if(it!=mp.end()) {
it->second=value;
putInFile(key,value);
remove(key, q);
q.push(key);
pthread_mutex_unlock(&l);
return;
}
else
{
if(mp.size()<len) {
mp[key]=value;
q.push(key);
putInFile(key,value);
pthread_mutex_unlock(&l);
return;
}
else
{
string cur=q.front();
q.pop();
mp.erase(cur);
mp[key]=value;
q.push(key);
putInFile(key,value);
pthread_mutex_unlock(&l);
return;
}
}
}
int del(string key) {
pthread_mutex_lock(&l);
mp.erase(key);
remove(key, q);
int i = delfromFile(key);
pthread_mutex_unlock(&l);
return i;
}
};
class LFUCache {
public:
// m tracks the minimum frequency at an instance of time
// s is the current s of the cache
// c is the maximum capacity of the cache
int m, s=0, c=0;
// The Cache(hashmap) where key and <values,frequency> are stored
unordered_map<string, pair<string, int>> Cache;
// Hashmap mapped from frequency to keylist, ie, each frequency is mapped to a list of keys
unordered_map<int, list<string>> temp1;
// Hashmap that maps the key to its position in the list freq_keylist[freq]
unordered_map<string, list<string>::iterator> temp2;
//constructor for LFU cache
LFUCache(int capacity) {
c = capacity;
pthread_mutex_init(&l,NULL);
}
string get(string key) {
pthread_mutex_lock(&l);
if(Cache.find(key)==Cache.end()) {
string v = getFromFile(key);
if(!v.compare("0")) {
pthread_mutex_unlock(&l);
return "key not found";
}
else{
add(key,v);
pthread_mutex_unlock(&l);
return v;
}
}
int freq = Cache[key].second;
temp1[freq].erase(temp2[key]);
Cache[key].second++;
temp1[Cache[key].second].push_back(key);
temp2[key] = --temp1[Cache[key].second].end();
int z = temp1[m].size();
if(z==0) m++;
pthread_mutex_unlock(&l);
return Cache[key].first;
}
void add(string key,string value){
if(c<=0) return;
// when the key in found in the cache
if(Cache.find(key)!=Cache.end()){
string abcde = get(key);
Cache[key].first = value;
return;
}
// when key is not found in the cache
if(s==c){
//remove the element from cache with min freq
string remove_key = temp1[m].front();
temp2.erase(remove_key);
Cache.erase(remove_key);
temp1[m].pop_front();
}
Cache[key] = {value, 1};
temp1[1].push_back(key);
temp2[key] = --temp1[1].end();
m=1;
if(s < c) s++;
}
void put(string key, string value) {
pthread_mutex_lock(&l);
if(c<=0){
pthread_mutex_unlock(&l);
return;
}
// when the key in found in the cache
if(Cache.find(key)!=Cache.end()){
//string abcde = get(key);
Cache[key].first = value;
putInFile(key,value);
int freq = Cache[key].second;
temp1[freq].erase(temp2[key]);
Cache[key].second++;
temp1[Cache[key].second].push_back(key);
temp2[key] = --temp1[Cache[key].second].end();
int z = temp1[m].size();
if(z==0) m++;
pthread_mutex_unlock(&l);
return;
}
// when key is not found in the cache
putInFile(key,value);
if(s==c){
//remove the element from cache with min freq
string remove_key = temp1[m].front();
temp2.erase(remove_key);
Cache.erase(remove_key);
temp1[m].pop_front();
}
Cache[key] = {value, 1};
temp1[1].push_back(key);
temp2[key] = --temp1[1].end();
m=1;
if(s < c) s++;
pthread_mutex_unlock(&l);
}
int del(string key) {
pthread_mutex_lock(&l);
int i = delfromFile(key);
if(Cache.find(key)==Cache.end()){
cout << "key" << " : " << key << "->" <<"Not present in cache" << " ";
}
else {
int f = Cache[key].second;
temp2.erase(key);
Cache.erase(key);
temp1[f].remove(key);
s--;
}
pthread_mutex_unlock(&l);
return i;
}
};
\ No newline at end of file
[ZoneTransfer]
ZoneId=3
HostUrl=https://web.whatsapp.com/
#include <iostream>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
string getFromFile(string key)
{
fstream file;
file.open("../../storage/a.txt",ios::in);
if(file.is_open())
{
string line,k,v;
v = "0";
while (getline(file, line))
{
stringstream stream(line);
getline(stream, k,' ');
if(k == key)
{
getline(stream,v);
break;
}
}
file.close();
return v;
}
return "0";
}
void putInFile(string key, string value)
{
string line,k,v,add;;
ifstream in("../../storage/a.txt");
if( !in.is_open())
{
in.close();
ofstream out("../../storage/a.txt");
add = key+' '+value;
out << add << "\n";
out.close();
return;
}
ofstream out("../../storage/o.txt");
while( getline(in,line) )
{
stringstream stream(line);
getline(stream, k,' ');
if(k != key)
{
getline(stream, v);
add = k+' '+v;
out << add << "\n";
}
}
add = key+' '+value;
out << add << "\n";
in.close();
out.close();
remove("../../storage/a.txt");
rename("../../storage/o.txt","../../storage/a.txt");
return;
}
int delfromFile(string key)
{
string line,k,v,add;
int flag=0;
ifstream in("../../storage/a.txt");
if( !in.is_open())
{
return -1;
}
ofstream out("../../storage/o.txt");
while( getline(in,line) )
{
stringstream stream(line);
getline(stream, k,' ');
if(k != key)
{
getline(stream, v);
add = k+' '+v;
out << add << "\n";
}
else
{
flag=1;
}
}
in.close();
out.close();
remove("../../storage/a.txt");
rename("../../storage/o.txt","../../storage/a.txt");
if (flag==0)
{
return -2;
}
return 0;
}
\ No newline at end of file
PUT key value
PUT key1 value1
PUT key2 value2
GET key
PUT key3 value3
DEL key1
DEL key3
GET key3
\ No newline at end of file
LISTENING_PORT=8081
CACHE_REPLACEMENT_TYPE=LRU
CACHE_SIZE=3
THREAD_POOL_SIZE=5
\ No newline at end of file
#include <iostream>
#include <memory>
#include <string>
#include<bits/stdc++.h>
#include <grpc/support/log.h>
#include <grpcpp/grpcpp.h>
#include "keyvaluestore.grpc.pb.h"
using grpc::Channel;
using grpc::ClientAsyncResponseReader;
using grpc::ClientContext;
using grpc::CompletionQueue;
using grpc::Status;
using kvstore::KeyValueStore;
using kvstore::Request;
using kvstore::Response;
class KeyValueClient {
public:
explicit KeyValueClient(std::shared_ptr<Channel> channel)
: stub_(KeyValueStore::NewStub(channel)) {}
// Assembles the client's payload, sends it and presents the response back
// from the server.
std::string GetValues(const std::string& user) {
// Data we are sending to the server.
Request request;
request.set_key(user);
request.set_type(1);
// Container for the data we expect from the server.
Response response;
// Context for the client. It could be used to convey extra information to
// the server and/or tweak certain RPC behaviors.
ClientContext context;
// The producer-consumer queue we use to communicate asynchronously with the
// gRPC runtime.
CompletionQueue cq;
// Storage for the status of the RPC upon completion.
Status status;
// stub_->PrepareAsyncSayHello() creates an RPC object, returning
// an instance to store in "call" but does not actually start the RPC
// Because we are using the asynchronous API, we need to hold on to
// the "call" instance in order to get updates on the ongoing RPC.
std::unique_ptr<ClientAsyncResponseReader<Response> > rpc(
stub_->PrepareAsyncStorePair(&context, request, &cq));
// StartCall initiates the RPC call
rpc->StartCall();
// Request that, upon completion of the RPC, "reply" be updated with the
// server's response; "status" with the indication of whether the operation
// was successful. Tag the request with the integer 1.
rpc->Finish(&response, &status, (void*)1);
void* got_tag;
bool ok = false;
// Block until the next result is available in the completion queue "cq".
// The return value of Next should always be checked. This return value
// tells us whether there is any kind of event or the cq_ is shutting down.
GPR_ASSERT(cq.Next(&got_tag, &ok));
// Verify that the result from "cq" corresponds, by its tag, our previous
// request.
GPR_ASSERT(got_tag == (void*)1);
// ... and that the request was completed successfully. Note that "ok"
// corresponds solely to the request for updates introduced by Finish().
GPR_ASSERT(ok);
// Act upon the status of the actual RPC.
if (status.ok()) {
return response.value();
} else {
return "RPC failed";
}
}
std::string StorePair(const std::string& p,const std::string& r) {
// Data we are sending to the server.
Request request;
request.set_key(p);
request.set_value(r);
request.set_type(2);
// Container for the data we expect from the server.
Response response;
// Context for the client. It could be used to convey extra information to
// the server and/or tweak certain RPC behaviors.
ClientContext context;
// The producer-consumer queue we use to communicate asynchronously with the
// gRPC runtime.
CompletionQueue cq;
// Storage for the status of the RPC upon completion.
Status status;
// stub_->PrepareAsyncSayHello() creates an RPC object, returning
// an instance to store in "call" but does not actually start the RPC
// Because we are using the asynchronous API, we need to hold on to
// the "call" instance in order to get updates on the ongoing RPC.
std::unique_ptr<ClientAsyncResponseReader<Response> > rpc(
stub_->PrepareAsyncStorePair(&context, request, &cq));
// StartCall initiates the RPC call
rpc->StartCall();
// Request that, upon completion of the RPC, "reply" be updated with the
// server's response; "status" with the indication of whether the operation
// was successful. Tag the request with the integer 1.
rpc->Finish(&response, &status, (void*)1);
void* got_tag;
bool ok = false;
// Block until the next result is available in the completion queue "cq".
// The return value of Next should always be checked. This return value
// tells us whether there is any kind of event or the cq_ is shutting down.
GPR_ASSERT(cq.Next(&got_tag, &ok));
// Verify that the result from "cq" corresponds, by its tag, our previous
// request.
GPR_ASSERT(got_tag == (void*)1);
// ... and that the request was completed successfully. Note that "ok"
// corresponds solely to the request for updates introduced by Finish().
GPR_ASSERT(ok);
// Act upon the status of the actual RPC.
if (status.ok()) {
return response.value();
} else {
return "RPC failed";
}
}
std::string DeletePair(const std::string& user) {
// Data we are sending to the server.
Request request;
request.set_key(user);
request.set_type(3);
// Container for the data we expect from the server.
Response response;
// Context for the client. It could be used to convey extra information to
// the server and/or tweak certain RPC behaviors.
ClientContext context;
// The producer-consumer queue we use to communicate asynchronously with the
// gRPC runtime.
CompletionQueue cq;
// Storage for the status of the RPC upon completion.
Status status;
// stub_->PrepareAsyncSayHello() creates an RPC object, returning
// an instance to store in "call" but does not actually start the RPC
// Because we are using the asynchronous API, we need to hold on to
// the "call" instance in order to get updates on the ongoing RPC.
std::unique_ptr<ClientAsyncResponseReader<Response> > rpc(
stub_->PrepareAsyncStorePair(&context, request, &cq));
// StartCall initiates the RPC call
rpc->StartCall();
// Request that, upon completion of the RPC, "reply" be updated with the
// server's response; "status" with the indication of whether the operation
// was successful. Tag the request with the integer 1.
rpc->Finish(&response, &status, (void*)1);
void* got_tag;
bool ok = false;
// Block until the next result is available in the completion queue "cq".
// The return value of Next should always be checked. This return value
// tells us whether there is any kind of event or the cq_ is shutting down.
GPR_ASSERT(cq.Next(&got_tag, &ok));
// Verify that the result from "cq" corresponds, by its tag, our previous
// request.
GPR_ASSERT(got_tag == (void*)1);
// ... and that the request was completed successfully. Note that "ok"
// corresponds solely to the request for updates introduced by Finish().
GPR_ASSERT(ok);
// Act upon the status of the actual RPC.
if (status.ok()) {
return response.value();
} else {
return "RPC failed";
}
}
private:
// Out of the passed in Channel comes the stub, stored here, our view of the
// server's exposed services.
std::unique_ptr<KeyValueStore::Stub> stub_;
};
int main(int argc, char** argv) {
// Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint (in this case,
// localhost at port 50051). We indicate that the channel isn't authenticated
// (use of InsecureChannelCredentials()).
std::map<std::string, int> config = std::map<std::string, int>();
std::fstream file;
file.open("../../config.conf", std::ios::in);
if (file.is_open()) {
std::string line, k, v;
while (getline(file, line)) {
std::stringstream stream(line);
getline(stream, k, '=');
getline(stream, v);
std::stringstream ss (v);
int val = 0;
if(k=="CACHE_REPLACEMENT_TYPE"){
if (v == "LFU") {
val = 1;
}
else {
val = 2;
}
}
else {
ss >> val;
}
config[k] = val;
}
file.close();
}
std::map<std::string, int>::iterator itr;
int port;
for (itr = config.begin(); itr != config.end(); itr++)
{
if(itr->first=="LISTENING_PORT")
port = itr->second;
}
KeyValueClient client(grpc::CreateChannel(
"localhost:"+ std::to_string(port), grpc::InsecureChannelCredentials()));
std::cout << "Choose Mode of " << std::endl;
std::cout << "For Interactive Mode enter 1 , For Batch Mode enter 2"<<std::endl;
int mode;
std::cin >> mode;
if(mode == 1) {
int i = 1;
std::string arg,arg1,arg2;
while(i==1) {
std::cout<<"Enter type of query : GET/PUT/DEL ";
std::cin >> arg;
if (arg == "GET") {
std::cout << "Enter Key : ";
std::cin >> arg1;
if (arg1.length() > 256)
std::cout << "key must be less then or equal to 256 characters" << std::endl;
else {
std::string reply = client.GetValues(arg1); // The actual RPC call!
std::cout << arg1 << ":" << reply << std::endl;
}
} else if (arg == "PUT") {
std::cout << "Enter Key and Value :";
std::cin >> arg1>>arg2;
if (arg1.length() > 256 || arg2.length() > 256)
std::cout << "key must be less then or equal to 256 characters" << std::endl;
else {
std::string q = client.StorePair(arg1, arg2);
std::cout << q << std::endl;
}
} else if (arg == "DEL") {
std::cout << "Enter Key : ";
std::cin >> arg1;
if (arg1.length() > 256)
std::cout << "key must be less then or equal to 256 characters" << std::endl;
else {
std::string q = client.DeletePair(arg1);
std::cout << q << std::endl;
}
}
std::cout << "Do you want To Continue " << std::endl;
std::cout << "If yes then enter 1 else 2 : ";
std::cin >> i;
}
}
else if(mode == 2) {
std::vector<std::vector<std::string>> cmds = std::vector<std::vector<std::string>>();
std::fstream file;
file.open("../../commands.conf", std::ios::in);
std::string line, k, v, readcmd;
while (getline(file, line)) {
std::vector<std::string> command = std::vector<std::string>();
std::stringstream stream(line);
getline(stream, readcmd, ' ');
getline(stream, k, ' ');
getline(stream, v);
command.emplace_back(readcmd);
command.emplace_back(k);
command.emplace_back(v);
cmds.emplace_back(command);
}
file.close();
for (const auto a: cmds) {
std::string arg1 = a.at(0);
std::string arg2, arg3;
if (arg1 == "GET") {
arg2 = a.at(1);
if (arg2.length() > 256)
std::cout << "key must be less then or equal to 256 characters" << std::endl;
else {
std::string reply = client.GetValues(arg2); // The actual RPC call!
std::cout << arg2 << ":" << reply << std::endl;
}
} else if (arg1 == "PUT") {
arg2 = a.at(1);
arg3 = a.at(2);
if (arg2.length() > 256 || arg3.length() > 256)
std::cout << "key must be less then or equal to 256 characters" << std::endl;
else {
std::string q = client.StorePair(arg2, arg3);
std::cout << q << std::endl;
}
} else if (arg1 == "DEL") {
arg2 = a.at(1);
if (arg2.length() > 256)
std::cout << "key must be less then or equal to 256 characters" << std::endl;
else {
std::string q = client.DeletePair(arg2);
std::cout << q << std::endl;
}
}
}
}
else
std::cout << "You have entered Wrong Input Run client again"<<std::endl;
return 0;
}
\ No newline at end of file
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include <grpc/support/log.h>
#include <grpcpp/grpcpp.h>
#include "KVCache.cpp"
#include "keyvaluestore.grpc.pb.h"
using grpc::Server;
using grpc::ServerAsyncResponseWriter;
using grpc::ServerBuilder;
using grpc::ServerCompletionQueue;
using grpc::ServerContext;
using grpc::Status;
using kvstore::KeyValueStore;
using kvstore::Request;
using kvstore::Response;
int port,size,policy,poolsize;
class ServerImpl final {
public:
~ServerImpl() {
server_->Shutdown();
// Always shutdown the completion queue after the server.
for(auto &i : cq_list){
i->Shutdown();
}
}
// There is no shutdown handling in this code.
void Run() {
std::string server_address("0.0.0.0:"+ std::to_string(port));
ServerBuilder builder;
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
// Register "service_" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *asynchronous* service.
builder.RegisterService(&service_);
// Get hold of the completion queue used for the asynchronous communication
// with the gRPC runtime.
for (auto i = 0; i < poolsize; i++) {
cq_list.emplace_back(builder.AddCompletionQueue());
}
// Finally assemble the server.
server_ = builder.BuildAndStart();
std::cout << "Server listening on " << server_address << std::endl;
std::vector<std::thread *> threads;
for (auto i = 0; i < poolsize; i++) {
threads.emplace_back(new std::thread(&ServerImpl::HandleRpcs, this, i));
}
for (const auto &t: threads) {
t->join();
}
}
private:
// Class encompasing the state and logic needed to serve a request.
class CallData {
public:
// Take in the "service" instance (in this case representing an asynchronous
// server) and the completion queue "cq" used for asynchronous communication
// with the gRPC runtime.
CallData(KeyValueStore::AsyncService* service, ServerCompletionQueue* cq, LRUCache* cache, LFUCache* lfucache)
: service_(service), cq_(cq), responder_(&ctx_), status_(CREATE), cache(cache), lfucache(lfucache){
// Invoke the serving logic right away.
Proceed();
}
void Proceed() {
if (status_ == CREATE) {
// Make this instance progress to the PROCESS state.
status_ = PROCESS;
// As part of the initial CREATE state, we *request* that the system
// start processing SayHello requests. In this request, "this" acts are
// the tag uniquely identifying the request (so that different CallData
// instances can serve different requests concurrently), in this case
// the memory address of this CallData instance.
service_->RequestGetValues(&ctx_, &request_, &responder_, cq_, cq_,
this);
service_->RequestStorePair(&ctx_, &request_, &responder_, cq_, cq_,
this);
service_->RequestDeletePair(&ctx_, &request_, &responder_, cq_, cq_,
this);
} else if (status_ == PROCESS) {
// Spawn a new CallData instance to serve new clients while we process
// the one for this CallData. The instance will deallocate itself as
// part of its FINISH state.
new CallData(service_, cq_, cache,lfucache);
// The actual processing.
if (request_.type() == 1)
{
if(policy == 1)
{
std::string val = lfucache->get(request_.key());
std::cout << "Found Value for : "<< request_.key() << " : " << val << std::endl;
reply_.set_value(val);
}
else{
std::string val = cache->get(request_.key());
std::cout << "Found Value for : "<< request_.key() << " : " << val << std::endl;
reply_.set_value(val);
}
}
else if (request_.type() == 2)
{
if(policy == 1)
{
lfucache->put(request_.key(),request_.value());
std::cout << "Insertion Successfull : "<<request_.key() << " " << request_.value() << std::endl;
reply_.set_value("Insertion Successfull");
}
else{
cache->put(request_.key(),request_.value());
std::cout << "Insertion Successfull : "<<request_.key() << " " << request_.value() << std::endl;
reply_.set_value("Insertion Successfull");
}
}
else if (request_.type() == 3)
{
if(policy == 1)
{
int i = lfucache->del(request_.key());
if(i == 0) {
std::cout<<"Deletion For key : "<<request_.key()<<": Successfull"<< std::endl;
reply_.set_value("Deletion Successfull");
}
else if(i==-1) {
std::cout<<"Deletion For key : "<<request_.key()<<": File Does not open"<< std::endl;
reply_.set_value("File Does not open");
}
else if(i == -2) {
std::cout<<"Deletion For key : "<<request_.key()<<": Key not present in File"<< std::endl;
reply_.set_value("Key not present in File");
}
}
else{
int i = cache->del(request_.key());
if(i == 0) {
std::cout<<"Deletion For key : "<<request_.key()<<": Successfull"<< std::endl;
reply_.set_value("Deletion Successfull");
}
else if(i==-1) {
std::cout<<"Deletion For key : "<<request_.key()<<": File Does not open"<< std::endl;
reply_.set_value("File Does not open");
}
else if(i == -2) {
std::cout<<"Deletion For key : "<<request_.key()<<": Key not present in File"<< std::endl;
reply_.set_value("Key not present in File");
}
}
}
// And we are done! Let the gRPC runtime know we've finished, using the
// memory address of this instance as the uniquely identifying tag for
// the event.
status_ = FINISH;
responder_.Finish(reply_, Status::OK, this);
} else {
GPR_ASSERT(status_ == FINISH);
// Once in the FINISH state, deallocate ourselves (CallData).
delete this;
}
}
private:
// The means of communication with the gRPC runtime for an asynchronous
// server.
KeyValueStore::AsyncService* service_;
// The producer-consumer queue where for asynchronous server notifications.
ServerCompletionQueue* cq_;
// Context for the rpc, allowing to tweak aspects of it such as the use
// of compression, authentication, as well as to send metadata back to the
// client.
ServerContext ctx_;
// What we get from the client.
Request request_;
// What we send back to the client.
Response reply_;
// The means to get back to the client.
ServerAsyncResponseWriter<Response> responder_;
// Let's implement a tiny state machine with the following states.
enum CallStatus { CREATE, PROCESS, FINISH };
CallStatus status_; // The current serving state.
LRUCache *cache;
LFUCache *lfucache;
};
// This can be run in multiple threads if needed.
void HandleRpcs(int index) {
// Spawn a new CallData instance to serve new clients.
LRUCache *cache = new LRUCache(size);
LFUCache *lfucache = new LFUCache(size);
new CallData(&service_, cq_list[index].get(), cache, lfucache);
void* tag; // uniquely identifies a request.
bool ok;
while (true) {
// Block waiting to read the next event from the completion queue. The
// event is uniquely identified by its tag, which in this case is the
// memory address of a CallData instance.
// The return value of Next should always be checked. This return value
// tells us whether there is any kind of event or cq_ is shutting down.
GPR_ASSERT(cq_list[index]->Next(&tag, &ok));
GPR_ASSERT(ok);
static_cast<CallData*>(tag)->Proceed();
}
}
std::vector<std::unique_ptr<ServerCompletionQueue>> cq_list;
KeyValueStore::AsyncService service_;
std::unique_ptr<Server> server_;
};
int main(int argc, char** argv) {
std::map<std::string, int> config = std::map<std::string, int>();
std::fstream file;
file.open("../../config.conf", std::ios::in);
if (file.is_open()) {
std::string line, k, v;
while (getline(file, line)) {
std::stringstream stream(line);
getline(stream, k, '=');
getline(stream, v);
std::stringstream ss (v);
int val = 0;
if(k=="CACHE_REPLACEMENT_TYPE"){
if (v == "LFU") {
val = 1;
}
else {
val = 2;
}
}
else {
ss >> val;
}
config[k] = val;
}
file.close();
}
std::map<std::string, int>::iterator itr;
for (itr = config.begin(); itr != config.end(); itr++)
{
if(itr->first=="LISTENING_PORT")
port = itr->second;
else if(itr->first=="CACHE_SIZE")
size = itr->second;
else if(itr->first=="CACHE_REPLACEMENT_TYPE")
policy = itr->second;
else if(itr->first=="THREAD_POOL_SIZE")
poolsize = itr->second;
}
ServerImpl server;
server.Run();
return 0;
}
\ No newline at end of file
// Generated by the gRPC C++ plugin.
// If you make any local change, they will be lost.
// source: keyvaluestore.proto
#include "keyvaluestore.pb.h"
#include "keyvaluestore.grpc.pb.h"
#include <functional>
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h>
#include <grpcpp/impl/codegen/channel_interface.h>
#include <grpcpp/impl/codegen/client_unary_call.h>
#include <grpcpp/impl/codegen/client_callback.h>
#include <grpcpp/impl/codegen/message_allocator.h>
#include <grpcpp/impl/codegen/method_handler.h>
#include <grpcpp/impl/codegen/rpc_service_method.h>
#include <grpcpp/impl/codegen/server_callback.h>
#include <grpcpp/impl/codegen/server_callback_handlers.h>
#include <grpcpp/impl/codegen/server_context.h>
#include <grpcpp/impl/codegen/service_type.h>
#include <grpcpp/impl/codegen/sync_stream.h>
namespace kvstore {
static const char* KeyValueStore_method_names[] = {
"/kvstore.KeyValueStore/GetValues",
"/kvstore.KeyValueStore/StorePair",
"/kvstore.KeyValueStore/DeletePair",
};
std::unique_ptr< KeyValueStore::Stub> KeyValueStore::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
(void)options;
std::unique_ptr< KeyValueStore::Stub> stub(new KeyValueStore::Stub(channel, options));
return stub;
}
KeyValueStore::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options)
: channel_(channel), rpcmethod_GetValues_(KeyValueStore_method_names[0], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_StorePair_(KeyValueStore_method_names[1], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_DeletePair_(KeyValueStore_method_names[2], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
{}
::grpc::Status KeyValueStore::Stub::GetValues(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) {
return ::grpc::internal::BlockingUnaryCall< ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_GetValues_, context, request, response);
}
void KeyValueStore::Stub::async::GetValues(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)> f) {
::grpc::internal::CallbackUnaryCall< ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_GetValues_, context, request, response, std::move(f));
}
void KeyValueStore::Stub::async::GetValues(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) {
::grpc::internal::ClientCallbackUnaryFactory::Create< ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_GetValues_, context, request, response, reactor);
}
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* KeyValueStore::Stub::PrepareAsyncGetValuesRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::kvstore::Response, ::kvstore::Request, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_GetValues_, context, request);
}
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* KeyValueStore::Stub::AsyncGetValuesRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
auto* result =
this->PrepareAsyncGetValuesRaw(context, request, cq);
result->StartCall();
return result;
}
::grpc::Status KeyValueStore::Stub::StorePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) {
return ::grpc::internal::BlockingUnaryCall< ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_StorePair_, context, request, response);
}
void KeyValueStore::Stub::async::StorePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)> f) {
::grpc::internal::CallbackUnaryCall< ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_StorePair_, context, request, response, std::move(f));
}
void KeyValueStore::Stub::async::StorePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) {
::grpc::internal::ClientCallbackUnaryFactory::Create< ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_StorePair_, context, request, response, reactor);
}
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* KeyValueStore::Stub::PrepareAsyncStorePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::kvstore::Response, ::kvstore::Request, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_StorePair_, context, request);
}
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* KeyValueStore::Stub::AsyncStorePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
auto* result =
this->PrepareAsyncStorePairRaw(context, request, cq);
result->StartCall();
return result;
}
::grpc::Status KeyValueStore::Stub::DeletePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) {
return ::grpc::internal::BlockingUnaryCall< ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_DeletePair_, context, request, response);
}
void KeyValueStore::Stub::async::DeletePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)> f) {
::grpc::internal::CallbackUnaryCall< ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_DeletePair_, context, request, response, std::move(f));
}
void KeyValueStore::Stub::async::DeletePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) {
::grpc::internal::ClientCallbackUnaryFactory::Create< ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_DeletePair_, context, request, response, reactor);
}
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* KeyValueStore::Stub::PrepareAsyncDeletePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::kvstore::Response, ::kvstore::Request, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_DeletePair_, context, request);
}
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* KeyValueStore::Stub::AsyncDeletePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
auto* result =
this->PrepareAsyncDeletePairRaw(context, request, cq);
result->StartCall();
return result;
}
KeyValueStore::Service::Service() {
AddMethod(new ::grpc::internal::RpcServiceMethod(
KeyValueStore_method_names[0],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< KeyValueStore::Service, ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](KeyValueStore::Service* service,
::grpc::ServerContext* ctx,
const ::kvstore::Request* req,
::kvstore::Response* resp) {
return service->GetValues(ctx, req, resp);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
KeyValueStore_method_names[1],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< KeyValueStore::Service, ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](KeyValueStore::Service* service,
::grpc::ServerContext* ctx,
const ::kvstore::Request* req,
::kvstore::Response* resp) {
return service->StorePair(ctx, req, resp);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
KeyValueStore_method_names[2],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< KeyValueStore::Service, ::kvstore::Request, ::kvstore::Response, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](KeyValueStore::Service* service,
::grpc::ServerContext* ctx,
const ::kvstore::Request* req,
::kvstore::Response* resp) {
return service->DeletePair(ctx, req, resp);
}, this)));
}
KeyValueStore::Service::~Service() {
}
::grpc::Status KeyValueStore::Service::GetValues(::grpc::ServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response) {
(void) context;
(void) request;
(void) response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status KeyValueStore::Service::StorePair(::grpc::ServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response) {
(void) context;
(void) request;
(void) response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status KeyValueStore::Service::DeletePair(::grpc::ServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response) {
(void) context;
(void) request;
(void) response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
} // namespace kvstore
// Generated by the gRPC C++ plugin.
// If you make any local change, they will be lost.
// source: keyvaluestore.proto
// Original file comments:
// Copyright 2018 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef GRPC_keyvaluestore_2eproto__INCLUDED
#define GRPC_keyvaluestore_2eproto__INCLUDED
#include "keyvaluestore.pb.h"
#include <functional>
#include <grpcpp/impl/codegen/async_generic_service.h>
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h>
#include <grpcpp/impl/codegen/client_callback.h>
#include <grpcpp/impl/codegen/client_context.h>
#include <grpcpp/impl/codegen/completion_queue.h>
#include <grpcpp/impl/codegen/message_allocator.h>
#include <grpcpp/impl/codegen/method_handler.h>
#include <grpcpp/impl/codegen/proto_utils.h>
#include <grpcpp/impl/codegen/rpc_method.h>
#include <grpcpp/impl/codegen/server_callback.h>
#include <grpcpp/impl/codegen/server_callback_handlers.h>
#include <grpcpp/impl/codegen/server_context.h>
#include <grpcpp/impl/codegen/service_type.h>
#include <grpcpp/impl/codegen/status.h>
#include <grpcpp/impl/codegen/stub_options.h>
#include <grpcpp/impl/codegen/sync_stream.h>
namespace kvstore {
// A simple key-value storage service
class KeyValueStore final {
public:
static constexpr char const* service_full_name() {
return "kvstore.KeyValueStore";
}
class StubInterface {
public:
virtual ~StubInterface() {}
// Provides a value for each key request
virtual ::grpc::Status GetValues(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) = 0;
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>> AsyncGetValues(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>>(AsyncGetValuesRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>> PrepareAsyncGetValues(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>>(PrepareAsyncGetValuesRaw(context, request, cq));
}
virtual ::grpc::Status StorePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) = 0;
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>> AsyncStorePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>>(AsyncStorePairRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>> PrepareAsyncStorePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>>(PrepareAsyncStorePairRaw(context, request, cq));
}
virtual ::grpc::Status DeletePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) = 0;
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>> AsyncDeletePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>>(AsyncDeletePairRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>> PrepareAsyncDeletePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>>(PrepareAsyncDeletePairRaw(context, request, cq));
}
class async_interface {
public:
virtual ~async_interface() {}
// Provides a value for each key request
virtual void GetValues(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)>) = 0;
virtual void GetValues(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) = 0;
virtual void StorePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)>) = 0;
virtual void StorePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) = 0;
virtual void DeletePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)>) = 0;
virtual void DeletePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) = 0;
};
typedef class async_interface experimental_async_interface;
virtual class async_interface* async() { return nullptr; }
class async_interface* experimental_async() { return async(); }
private:
virtual ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>* AsyncGetValuesRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>* PrepareAsyncGetValuesRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>* AsyncStorePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>* PrepareAsyncStorePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>* AsyncDeletePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::kvstore::Response>* PrepareAsyncDeletePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) = 0;
};
class Stub final : public StubInterface {
public:
Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
::grpc::Status GetValues(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) override;
std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>> AsyncGetValues(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>>(AsyncGetValuesRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>> PrepareAsyncGetValues(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>>(PrepareAsyncGetValuesRaw(context, request, cq));
}
::grpc::Status StorePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) override;
std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>> AsyncStorePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>>(AsyncStorePairRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>> PrepareAsyncStorePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>>(PrepareAsyncStorePairRaw(context, request, cq));
}
::grpc::Status DeletePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::kvstore::Response* response) override;
std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>> AsyncDeletePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>>(AsyncDeletePairRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>> PrepareAsyncDeletePair(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::kvstore::Response>>(PrepareAsyncDeletePairRaw(context, request, cq));
}
class async final :
public StubInterface::async_interface {
public:
void GetValues(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)>) override;
void GetValues(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) override;
void StorePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)>) override;
void StorePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) override;
void DeletePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, std::function<void(::grpc::Status)>) override;
void DeletePair(::grpc::ClientContext* context, const ::kvstore::Request* request, ::kvstore::Response* response, ::grpc::ClientUnaryReactor* reactor) override;
private:
friend class Stub;
explicit async(Stub* stub): stub_(stub) { }
Stub* stub() { return stub_; }
Stub* stub_;
};
class async* async() override { return &async_stub_; }
private:
std::shared_ptr< ::grpc::ChannelInterface> channel_;
class async async_stub_{this};
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* AsyncGetValuesRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* PrepareAsyncGetValuesRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* AsyncStorePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* PrepareAsyncStorePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* AsyncDeletePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::kvstore::Response>* PrepareAsyncDeletePairRaw(::grpc::ClientContext* context, const ::kvstore::Request& request, ::grpc::CompletionQueue* cq) override;
const ::grpc::internal::RpcMethod rpcmethod_GetValues_;
const ::grpc::internal::RpcMethod rpcmethod_StorePair_;
const ::grpc::internal::RpcMethod rpcmethod_DeletePair_;
};
static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
class Service : public ::grpc::Service {
public:
Service();
virtual ~Service();
// Provides a value for each key request
virtual ::grpc::Status GetValues(::grpc::ServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response);
virtual ::grpc::Status StorePair(::grpc::ServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response);
virtual ::grpc::Status DeletePair(::grpc::ServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response);
};
template <class BaseClass>
class WithAsyncMethod_GetValues : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithAsyncMethod_GetValues() {
::grpc::Service::MarkMethodAsync(0);
}
~WithAsyncMethod_GetValues() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetValues(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestGetValues(::grpc::ServerContext* context, ::kvstore::Request* request, ::grpc::ServerAsyncResponseWriter< ::kvstore::Response>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithAsyncMethod_StorePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithAsyncMethod_StorePair() {
::grpc::Service::MarkMethodAsync(1);
}
~WithAsyncMethod_StorePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status StorePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestStorePair(::grpc::ServerContext* context, ::kvstore::Request* request, ::grpc::ServerAsyncResponseWriter< ::kvstore::Response>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(1, context, request, response, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithAsyncMethod_DeletePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithAsyncMethod_DeletePair() {
::grpc::Service::MarkMethodAsync(2);
}
~WithAsyncMethod_DeletePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status DeletePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestDeletePair(::grpc::ServerContext* context, ::kvstore::Request* request, ::grpc::ServerAsyncResponseWriter< ::kvstore::Response>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(2, context, request, response, new_call_cq, notification_cq, tag);
}
};
typedef WithAsyncMethod_GetValues<WithAsyncMethod_StorePair<WithAsyncMethod_DeletePair<Service > > > AsyncService;
template <class BaseClass>
class WithCallbackMethod_GetValues : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithCallbackMethod_GetValues() {
::grpc::Service::MarkMethodCallback(0,
new ::grpc::internal::CallbackUnaryHandler< ::kvstore::Request, ::kvstore::Response>(
[this](
::grpc::CallbackServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response) { return this->GetValues(context, request, response); }));}
void SetMessageAllocatorFor_GetValues(
::grpc::MessageAllocator< ::kvstore::Request, ::kvstore::Response>* allocator) {
::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(0);
static_cast<::grpc::internal::CallbackUnaryHandler< ::kvstore::Request, ::kvstore::Response>*>(handler)
->SetMessageAllocator(allocator);
}
~WithCallbackMethod_GetValues() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetValues(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
virtual ::grpc::ServerUnaryReactor* GetValues(
::grpc::CallbackServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) { return nullptr; }
};
template <class BaseClass>
class WithCallbackMethod_StorePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithCallbackMethod_StorePair() {
::grpc::Service::MarkMethodCallback(1,
new ::grpc::internal::CallbackUnaryHandler< ::kvstore::Request, ::kvstore::Response>(
[this](
::grpc::CallbackServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response) { return this->StorePair(context, request, response); }));}
void SetMessageAllocatorFor_StorePair(
::grpc::MessageAllocator< ::kvstore::Request, ::kvstore::Response>* allocator) {
::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(1);
static_cast<::grpc::internal::CallbackUnaryHandler< ::kvstore::Request, ::kvstore::Response>*>(handler)
->SetMessageAllocator(allocator);
}
~WithCallbackMethod_StorePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status StorePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
virtual ::grpc::ServerUnaryReactor* StorePair(
::grpc::CallbackServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) { return nullptr; }
};
template <class BaseClass>
class WithCallbackMethod_DeletePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithCallbackMethod_DeletePair() {
::grpc::Service::MarkMethodCallback(2,
new ::grpc::internal::CallbackUnaryHandler< ::kvstore::Request, ::kvstore::Response>(
[this](
::grpc::CallbackServerContext* context, const ::kvstore::Request* request, ::kvstore::Response* response) { return this->DeletePair(context, request, response); }));}
void SetMessageAllocatorFor_DeletePair(
::grpc::MessageAllocator< ::kvstore::Request, ::kvstore::Response>* allocator) {
::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(2);
static_cast<::grpc::internal::CallbackUnaryHandler< ::kvstore::Request, ::kvstore::Response>*>(handler)
->SetMessageAllocator(allocator);
}
~WithCallbackMethod_DeletePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status DeletePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
virtual ::grpc::ServerUnaryReactor* DeletePair(
::grpc::CallbackServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) { return nullptr; }
};
typedef WithCallbackMethod_GetValues<WithCallbackMethod_StorePair<WithCallbackMethod_DeletePair<Service > > > CallbackService;
typedef CallbackService ExperimentalCallbackService;
template <class BaseClass>
class WithGenericMethod_GetValues : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithGenericMethod_GetValues() {
::grpc::Service::MarkMethodGeneric(0);
}
~WithGenericMethod_GetValues() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetValues(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
};
template <class BaseClass>
class WithGenericMethod_StorePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithGenericMethod_StorePair() {
::grpc::Service::MarkMethodGeneric(1);
}
~WithGenericMethod_StorePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status StorePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
};
template <class BaseClass>
class WithGenericMethod_DeletePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithGenericMethod_DeletePair() {
::grpc::Service::MarkMethodGeneric(2);
}
~WithGenericMethod_DeletePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status DeletePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
};
template <class BaseClass>
class WithRawMethod_GetValues : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithRawMethod_GetValues() {
::grpc::Service::MarkMethodRaw(0);
}
~WithRawMethod_GetValues() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetValues(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestGetValues(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithRawMethod_StorePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithRawMethod_StorePair() {
::grpc::Service::MarkMethodRaw(1);
}
~WithRawMethod_StorePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status StorePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestStorePair(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(1, context, request, response, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithRawMethod_DeletePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithRawMethod_DeletePair() {
::grpc::Service::MarkMethodRaw(2);
}
~WithRawMethod_DeletePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status DeletePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestDeletePair(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(2, context, request, response, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithRawCallbackMethod_GetValues : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithRawCallbackMethod_GetValues() {
::grpc::Service::MarkMethodRawCallback(0,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
[this](
::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->GetValues(context, request, response); }));
}
~WithRawCallbackMethod_GetValues() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetValues(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
virtual ::grpc::ServerUnaryReactor* GetValues(
::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; }
};
template <class BaseClass>
class WithRawCallbackMethod_StorePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithRawCallbackMethod_StorePair() {
::grpc::Service::MarkMethodRawCallback(1,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
[this](
::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->StorePair(context, request, response); }));
}
~WithRawCallbackMethod_StorePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status StorePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
virtual ::grpc::ServerUnaryReactor* StorePair(
::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; }
};
template <class BaseClass>
class WithRawCallbackMethod_DeletePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithRawCallbackMethod_DeletePair() {
::grpc::Service::MarkMethodRawCallback(2,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
[this](
::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->DeletePair(context, request, response); }));
}
~WithRawCallbackMethod_DeletePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status DeletePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
virtual ::grpc::ServerUnaryReactor* DeletePair(
::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; }
};
template <class BaseClass>
class WithStreamedUnaryMethod_GetValues : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithStreamedUnaryMethod_GetValues() {
::grpc::Service::MarkMethodStreamed(0,
new ::grpc::internal::StreamedUnaryHandler<
::kvstore::Request, ::kvstore::Response>(
[this](::grpc::ServerContext* context,
::grpc::ServerUnaryStreamer<
::kvstore::Request, ::kvstore::Response>* streamer) {
return this->StreamedGetValues(context,
streamer);
}));
}
~WithStreamedUnaryMethod_GetValues() override {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status GetValues(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
// replace default version of method with streamed unary
virtual ::grpc::Status StreamedGetValues(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::kvstore::Request,::kvstore::Response>* server_unary_streamer) = 0;
};
template <class BaseClass>
class WithStreamedUnaryMethod_StorePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithStreamedUnaryMethod_StorePair() {
::grpc::Service::MarkMethodStreamed(1,
new ::grpc::internal::StreamedUnaryHandler<
::kvstore::Request, ::kvstore::Response>(
[this](::grpc::ServerContext* context,
::grpc::ServerUnaryStreamer<
::kvstore::Request, ::kvstore::Response>* streamer) {
return this->StreamedStorePair(context,
streamer);
}));
}
~WithStreamedUnaryMethod_StorePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status StorePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
// replace default version of method with streamed unary
virtual ::grpc::Status StreamedStorePair(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::kvstore::Request,::kvstore::Response>* server_unary_streamer) = 0;
};
template <class BaseClass>
class WithStreamedUnaryMethod_DeletePair : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithStreamedUnaryMethod_DeletePair() {
::grpc::Service::MarkMethodStreamed(2,
new ::grpc::internal::StreamedUnaryHandler<
::kvstore::Request, ::kvstore::Response>(
[this](::grpc::ServerContext* context,
::grpc::ServerUnaryStreamer<
::kvstore::Request, ::kvstore::Response>* streamer) {
return this->StreamedDeletePair(context,
streamer);
}));
}
~WithStreamedUnaryMethod_DeletePair() override {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status DeletePair(::grpc::ServerContext* /*context*/, const ::kvstore::Request* /*request*/, ::kvstore::Response* /*response*/) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
// replace default version of method with streamed unary
virtual ::grpc::Status StreamedDeletePair(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::kvstore::Request,::kvstore::Response>* server_unary_streamer) = 0;
};
typedef WithStreamedUnaryMethod_GetValues<WithStreamedUnaryMethod_StorePair<WithStreamedUnaryMethod_DeletePair<Service > > > StreamedUnaryService;
typedef Service SplitStreamedService;
typedef WithStreamedUnaryMethod_GetValues<WithStreamedUnaryMethod_StorePair<WithStreamedUnaryMethod_DeletePair<Service > > > StreamedService;
};
} // namespace kvstore
#endif // GRPC_keyvaluestore_2eproto__INCLUDED
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: keyvaluestore.proto
#include "keyvaluestore.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
namespace kvstore {
constexpr Request::Request(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: key_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
, value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
, type_(0){}
struct RequestDefaultTypeInternal {
constexpr RequestDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~RequestDefaultTypeInternal() {}
union {
Request _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT RequestDefaultTypeInternal _Request_default_instance_;
constexpr Response::Response(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){}
struct ResponseDefaultTypeInternal {
constexpr ResponseDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ResponseDefaultTypeInternal() {}
union {
Response _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ResponseDefaultTypeInternal _Response_default_instance_;
} // namespace kvstore
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_keyvaluestore_2eproto[2];
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_keyvaluestore_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_keyvaluestore_2eproto = nullptr;
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_keyvaluestore_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::kvstore::Request, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::kvstore::Request, key_),
PROTOBUF_FIELD_OFFSET(::kvstore::Request, value_),
PROTOBUF_FIELD_OFFSET(::kvstore::Request, type_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::kvstore::Response, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::kvstore::Response, value_),
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::kvstore::Request)},
{ 8, -1, sizeof(::kvstore::Response)},
};
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::kvstore::_Request_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::kvstore::_Response_default_instance_),
};
const char descriptor_table_protodef_keyvaluestore_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\023keyvaluestore.proto\022\007kvstore\"3\n\007Reques"
"t\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t\022\014\n\004type\030\003 "
"\001(\005\"\031\n\010Response\022\r\n\005value\030\001 \001(\t2\254\001\n\rKeyVa"
"lueStore\0222\n\tGetValues\022\020.kvstore.Request\032"
"\021.kvstore.Response\"\000\0222\n\tStorePair\022\020.kvst"
"ore.Request\032\021.kvstore.Response\"\000\0223\n\nDele"
"tePair\022\020.kvstore.Request\032\021.kvstore.Respo"
"nse\"\000b\006proto3"
;
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_keyvaluestore_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_keyvaluestore_2eproto = {
false, false, 293, descriptor_table_protodef_keyvaluestore_2eproto, "keyvaluestore.proto",
&descriptor_table_keyvaluestore_2eproto_once, nullptr, 0, 2,
schemas, file_default_instances, TableStruct_keyvaluestore_2eproto::offsets,
file_level_metadata_keyvaluestore_2eproto, file_level_enum_descriptors_keyvaluestore_2eproto, file_level_service_descriptors_keyvaluestore_2eproto,
};
PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
descriptor_table_keyvaluestore_2eproto_metadata_getter(int index) {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_keyvaluestore_2eproto);
return descriptor_table_keyvaluestore_2eproto.file_level_metadata[index];
}
// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_keyvaluestore_2eproto(&descriptor_table_keyvaluestore_2eproto);
namespace kvstore {
// ===================================================================
class Request::_Internal {
public:
};
Request::Request(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) {
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:kvstore.Request)
}
Request::Request(const Request& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
key_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_key().empty()) {
key_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_key(),
GetArena());
}
value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_value().empty()) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(),
GetArena());
}
type_ = from.type_;
// @@protoc_insertion_point(copy_constructor:kvstore.Request)
}
void Request::SharedCtor() {
key_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
type_ = 0;
}
Request::~Request() {
// @@protoc_insertion_point(destructor:kvstore.Request)
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
void Request::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
key_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
void Request::ArenaDtor(void* object) {
Request* _this = reinterpret_cast< Request* >(object);
(void)_this;
}
void Request::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Request::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void Request::Clear() {
// @@protoc_insertion_point(message_clear_start:kvstore.Request)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
key_.ClearToEmpty();
value_.ClearToEmpty();
type_ = 0;
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* Request::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// string key = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
auto str = _internal_mutable_key();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "kvstore.Request.key"));
CHK_(ptr);
} else goto handle_unusual;
continue;
// string value = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
auto str = _internal_mutable_value();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "kvstore.Request.value"));
CHK_(ptr);
} else goto handle_unusual;
continue;
// int32 type = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
type_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* Request::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:kvstore.Request)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string key = 1;
if (this->key().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_key().data(), static_cast<int>(this->_internal_key().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"kvstore.Request.key");
target = stream->WriteStringMaybeAliased(
1, this->_internal_key(), target);
}
// string value = 2;
if (this->value().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_value().data(), static_cast<int>(this->_internal_value().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"kvstore.Request.value");
target = stream->WriteStringMaybeAliased(
2, this->_internal_value(), target);
}
// int32 type = 3;
if (this->type() != 0) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_type(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:kvstore.Request)
return target;
}
size_t Request::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:kvstore.Request)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string key = 1;
if (this->key().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_key());
}
// string value = 2;
if (this->value().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_value());
}
// int32 type = 3;
if (this->type() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
this->_internal_type());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void Request::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:kvstore.Request)
GOOGLE_DCHECK_NE(&from, this);
const Request* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Request>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:kvstore.Request)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:kvstore.Request)
MergeFrom(*source);
}
}
void Request::MergeFrom(const Request& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:kvstore.Request)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.key().size() > 0) {
_internal_set_key(from._internal_key());
}
if (from.value().size() > 0) {
_internal_set_value(from._internal_value());
}
if (from.type() != 0) {
_internal_set_type(from._internal_type());
}
}
void Request::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:kvstore.Request)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Request::CopyFrom(const Request& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:kvstore.Request)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Request::IsInitialized() const {
return true;
}
void Request::InternalSwap(Request* other) {
using std::swap;
_internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
key_.Swap(&other->key_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
swap(type_, other->type_);
}
::PROTOBUF_NAMESPACE_ID::Metadata Request::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
class Response::_Internal {
public:
};
Response::Response(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) {
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:kvstore.Response)
}
Response::Response(const Response& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_value().empty()) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(),
GetArena());
}
// @@protoc_insertion_point(copy_constructor:kvstore.Response)
}
void Response::SharedCtor() {
value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
Response::~Response() {
// @@protoc_insertion_point(destructor:kvstore.Response)
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
void Response::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
void Response::ArenaDtor(void* object) {
Response* _this = reinterpret_cast< Response* >(object);
(void)_this;
}
void Response::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Response::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void Response::Clear() {
// @@protoc_insertion_point(message_clear_start:kvstore.Response)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_.ClearToEmpty();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* Response::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// string value = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
auto str = _internal_mutable_value();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "kvstore.Response.value"));
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* Response::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:kvstore.Response)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string value = 1;
if (this->value().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_value().data(), static_cast<int>(this->_internal_value().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"kvstore.Response.value");
target = stream->WriteStringMaybeAliased(
1, this->_internal_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:kvstore.Response)
return target;
}
size_t Response::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:kvstore.Response)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string value = 1;
if (this->value().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_value());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void Response::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:kvstore.Response)
GOOGLE_DCHECK_NE(&from, this);
const Response* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Response>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:kvstore.Response)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:kvstore.Response)
MergeFrom(*source);
}
}
void Response::MergeFrom(const Response& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:kvstore.Response)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value().size() > 0) {
_internal_set_value(from._internal_value());
}
}
void Response::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:kvstore.Response)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Response::CopyFrom(const Response& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:kvstore.Response)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Response::IsInitialized() const {
return true;
}
void Response::InternalSwap(Response* other) {
using std::swap;
_internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
}
::PROTOBUF_NAMESPACE_ID::Metadata Response::GetMetadata() const {
return GetMetadataStatic();
}
// @@protoc_insertion_point(namespace_scope)
} // namespace kvstore
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::kvstore::Request* Arena::CreateMaybeMessage< ::kvstore::Request >(Arena* arena) {
return Arena::CreateMessageInternal< ::kvstore::Request >(arena);
}
template<> PROTOBUF_NOINLINE ::kvstore::Response* Arena::CreateMaybeMessage< ::kvstore::Response >(Arena* arena) {
return Arena::CreateMessageInternal< ::kvstore::Response >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: keyvaluestore.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_keyvaluestore_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_keyvaluestore_2eproto
#include <limits>
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3015000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3015008 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_keyvaluestore_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_keyvaluestore_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[2]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
};
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_keyvaluestore_2eproto;
::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_keyvaluestore_2eproto_metadata_getter(int index);
namespace kvstore {
class Request;
struct RequestDefaultTypeInternal;
extern RequestDefaultTypeInternal _Request_default_instance_;
class Response;
struct ResponseDefaultTypeInternal;
extern ResponseDefaultTypeInternal _Response_default_instance_;
} // namespace kvstore
PROTOBUF_NAMESPACE_OPEN
template<> ::kvstore::Request* Arena::CreateMaybeMessage<::kvstore::Request>(Arena*);
template<> ::kvstore::Response* Arena::CreateMaybeMessage<::kvstore::Response>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
namespace kvstore {
// ===================================================================
class Request PROTOBUF_FINAL :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:kvstore.Request) */ {
public:
inline Request() : Request(nullptr) {}
virtual ~Request();
explicit constexpr Request(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Request(const Request& from);
Request(Request&& from) noexcept
: Request() {
*this = ::std::move(from);
}
inline Request& operator=(const Request& from) {
CopyFrom(from);
return *this;
}
inline Request& operator=(Request&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return GetMetadataStatic().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return GetMetadataStatic().reflection;
}
static const Request& default_instance() {
return *internal_default_instance();
}
static inline const Request* internal_default_instance() {
return reinterpret_cast<const Request*>(
&_Request_default_instance_);
}
static constexpr int kIndexInFileMessages =
0;
friend void swap(Request& a, Request& b) {
a.Swap(&b);
}
inline void Swap(Request* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(Request* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Request* New() const final {
return CreateMaybeMessage<Request>(nullptr);
}
Request* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<Request>(arena);
}
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void CopyFrom(const Request& from);
void MergeFrom(const Request& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
inline void SharedCtor();
inline void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Request* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "kvstore.Request";
}
protected:
explicit Request(::PROTOBUF_NAMESPACE_ID::Arena* arena);
private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
private:
static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
return ::descriptor_table_keyvaluestore_2eproto_metadata_getter(kIndexInFileMessages);
}
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kKeyFieldNumber = 1,
kValueFieldNumber = 2,
kTypeFieldNumber = 3,
};
// string key = 1;
void clear_key();
const std::string& key() const;
void set_key(const std::string& value);
void set_key(std::string&& value);
void set_key(const char* value);
void set_key(const char* value, size_t size);
std::string* mutable_key();
std::string* release_key();
void set_allocated_key(std::string* key);
private:
const std::string& _internal_key() const;
void _internal_set_key(const std::string& value);
std::string* _internal_mutable_key();
public:
// string value = 2;
void clear_value();
const std::string& value() const;
void set_value(const std::string& value);
void set_value(std::string&& value);
void set_value(const char* value);
void set_value(const char* value, size_t size);
std::string* mutable_value();
std::string* release_value();
void set_allocated_value(std::string* value);
private:
const std::string& _internal_value() const;
void _internal_set_value(const std::string& value);
std::string* _internal_mutable_value();
public:
// int32 type = 3;
void clear_type();
::PROTOBUF_NAMESPACE_ID::int32 type() const;
void set_type(::PROTOBUF_NAMESPACE_ID::int32 value);
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_type() const;
void _internal_set_type(::PROTOBUF_NAMESPACE_ID::int32 value);
public:
// @@protoc_insertion_point(class_scope:kvstore.Request)
private:
class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr key_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_;
::PROTOBUF_NAMESPACE_ID::int32 type_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_keyvaluestore_2eproto;
};
// -------------------------------------------------------------------
class Response PROTOBUF_FINAL :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:kvstore.Response) */ {
public:
inline Response() : Response(nullptr) {}
virtual ~Response();
explicit constexpr Response(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Response(const Response& from);
Response(Response&& from) noexcept
: Response() {
*this = ::std::move(from);
}
inline Response& operator=(const Response& from) {
CopyFrom(from);
return *this;
}
inline Response& operator=(Response&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return GetMetadataStatic().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return GetMetadataStatic().reflection;
}
static const Response& default_instance() {
return *internal_default_instance();
}
static inline const Response* internal_default_instance() {
return reinterpret_cast<const Response*>(
&_Response_default_instance_);
}
static constexpr int kIndexInFileMessages =
1;
friend void swap(Response& a, Response& b) {
a.Swap(&b);
}
inline void Swap(Response* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(Response* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Response* New() const final {
return CreateMaybeMessage<Response>(nullptr);
}
Response* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<Response>(arena);
}
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void CopyFrom(const Response& from);
void MergeFrom(const Response& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
inline void SharedCtor();
inline void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Response* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "kvstore.Response";
}
protected:
explicit Response(::PROTOBUF_NAMESPACE_ID::Arena* arena);
private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
private:
static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
return ::descriptor_table_keyvaluestore_2eproto_metadata_getter(kIndexInFileMessages);
}
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kValueFieldNumber = 1,
};
// string value = 1;
void clear_value();
const std::string& value() const;
void set_value(const std::string& value);
void set_value(std::string&& value);
void set_value(const char* value);
void set_value(const char* value, size_t size);
std::string* mutable_value();
std::string* release_value();
void set_allocated_value(std::string* value);
private:
const std::string& _internal_value() const;
void _internal_set_value(const std::string& value);
std::string* _internal_mutable_value();
public:
// @@protoc_insertion_point(class_scope:kvstore.Response)
private:
class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_keyvaluestore_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// Request
// string key = 1;
inline void Request::clear_key() {
key_.ClearToEmpty();
}
inline const std::string& Request::key() const {
// @@protoc_insertion_point(field_get:kvstore.Request.key)
return _internal_key();
}
inline void Request::set_key(const std::string& value) {
_internal_set_key(value);
// @@protoc_insertion_point(field_set:kvstore.Request.key)
}
inline std::string* Request::mutable_key() {
// @@protoc_insertion_point(field_mutable:kvstore.Request.key)
return _internal_mutable_key();
}
inline const std::string& Request::_internal_key() const {
return key_.Get();
}
inline void Request::_internal_set_key(const std::string& value) {
key_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
}
inline void Request::set_key(std::string&& value) {
key_.Set(
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
// @@protoc_insertion_point(field_set_rvalue:kvstore.Request.key)
}
inline void Request::set_key(const char* value) {
GOOGLE_DCHECK(value != nullptr);
key_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
// @@protoc_insertion_point(field_set_char:kvstore.Request.key)
}
inline void Request::set_key(const char* value,
size_t size) {
key_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
reinterpret_cast<const char*>(value), size), GetArena());
// @@protoc_insertion_point(field_set_pointer:kvstore.Request.key)
}
inline std::string* Request::_internal_mutable_key() {
return key_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
}
inline std::string* Request::release_key() {
// @@protoc_insertion_point(field_release:kvstore.Request.key)
return key_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
}
inline void Request::set_allocated_key(std::string* key) {
if (key != nullptr) {
} else {
}
key_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), key,
GetArena());
// @@protoc_insertion_point(field_set_allocated:kvstore.Request.key)
}
// string value = 2;
inline void Request::clear_value() {
value_.ClearToEmpty();
}
inline const std::string& Request::value() const {
// @@protoc_insertion_point(field_get:kvstore.Request.value)
return _internal_value();
}
inline void Request::set_value(const std::string& value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:kvstore.Request.value)
}
inline std::string* Request::mutable_value() {
// @@protoc_insertion_point(field_mutable:kvstore.Request.value)
return _internal_mutable_value();
}
inline const std::string& Request::_internal_value() const {
return value_.Get();
}
inline void Request::_internal_set_value(const std::string& value) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
}
inline void Request::set_value(std::string&& value) {
value_.Set(
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
// @@protoc_insertion_point(field_set_rvalue:kvstore.Request.value)
}
inline void Request::set_value(const char* value) {
GOOGLE_DCHECK(value != nullptr);
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
// @@protoc_insertion_point(field_set_char:kvstore.Request.value)
}
inline void Request::set_value(const char* value,
size_t size) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
reinterpret_cast<const char*>(value), size), GetArena());
// @@protoc_insertion_point(field_set_pointer:kvstore.Request.value)
}
inline std::string* Request::_internal_mutable_value() {
return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
}
inline std::string* Request::release_value() {
// @@protoc_insertion_point(field_release:kvstore.Request.value)
return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
}
inline void Request::set_allocated_value(std::string* value) {
if (value != nullptr) {
} else {
}
value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value,
GetArena());
// @@protoc_insertion_point(field_set_allocated:kvstore.Request.value)
}
// int32 type = 3;
inline void Request::clear_type() {
type_ = 0;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 Request::_internal_type() const {
return type_;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 Request::type() const {
// @@protoc_insertion_point(field_get:kvstore.Request.type)
return _internal_type();
}
inline void Request::_internal_set_type(::PROTOBUF_NAMESPACE_ID::int32 value) {
type_ = value;
}
inline void Request::set_type(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_set_type(value);
// @@protoc_insertion_point(field_set:kvstore.Request.type)
}
// -------------------------------------------------------------------
// Response
// string value = 1;
inline void Response::clear_value() {
value_.ClearToEmpty();
}
inline const std::string& Response::value() const {
// @@protoc_insertion_point(field_get:kvstore.Response.value)
return _internal_value();
}
inline void Response::set_value(const std::string& value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:kvstore.Response.value)
}
inline std::string* Response::mutable_value() {
// @@protoc_insertion_point(field_mutable:kvstore.Response.value)
return _internal_mutable_value();
}
inline const std::string& Response::_internal_value() const {
return value_.Get();
}
inline void Response::_internal_set_value(const std::string& value) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
}
inline void Response::set_value(std::string&& value) {
value_.Set(
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
// @@protoc_insertion_point(field_set_rvalue:kvstore.Response.value)
}
inline void Response::set_value(const char* value) {
GOOGLE_DCHECK(value != nullptr);
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
// @@protoc_insertion_point(field_set_char:kvstore.Response.value)
}
inline void Response::set_value(const char* value,
size_t size) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
reinterpret_cast<const char*>(value), size), GetArena());
// @@protoc_insertion_point(field_set_pointer:kvstore.Response.value)
}
inline std::string* Response::_internal_mutable_value() {
return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
}
inline std::string* Response::release_value() {
// @@protoc_insertion_point(field_release:kvstore.Response.value)
return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
}
inline void Response::set_allocated_value(std::string* value) {
if (value != nullptr) {
} else {
}
value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value,
GetArena());
// @@protoc_insertion_point(field_set_allocated:kvstore.Response.value)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// -------------------------------------------------------------------
// @@protoc_insertion_point(namespace_scope)
} // namespace kvstore
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_keyvaluestore_2eproto
// Copyright 2018 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package kvstore;
// A simple key-value storage service
service KeyValueStore {
// Provides a value for each key request
rpc GetValues (Request) returns (Response) {}
rpc StorePair (Request) returns (Response) {}
rpc DeletePair (Request) returns (Response) {}
}
// The request message containing the key
message Request {
string key = 1;
string value = 2;
int32 type = 3;
}
// The response message containing the value associated with the key
message Response {
string value = 1;
}
sagar sagar
shiva shiva
ghana hello
key2 value2
key value
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment