aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2019-01-10 14:18:24 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2019-01-10 14:18:24 -0800
commitb72bb30126b8baf8b8140266bad2009e6d3c4ded (patch)
tree67f1de1267f9951566c9642e900cf3cd1fde2a06
parentaa5950936923437b45dbe75f5d981033ec00a2f9 (diff)
Clang format
-rw-r--r--examples/cpp/keyvaluestore/client.cc8
-rw-r--r--examples/cpp/keyvaluestore/server.cc20
2 files changed, 13 insertions, 15 deletions
diff --git a/examples/cpp/keyvaluestore/client.cc b/examples/cpp/keyvaluestore/client.cc
index e956a16573..17e407c273 100644
--- a/examples/cpp/keyvaluestore/client.cc
+++ b/examples/cpp/keyvaluestore/client.cc
@@ -32,9 +32,9 @@
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
+using keyvaluestore::KeyValueStore;
using keyvaluestore::Request;
using keyvaluestore::Response;
-using keyvaluestore::KeyValueStore;
class KeyValueStoreClient {
public:
@@ -48,7 +48,7 @@ class KeyValueStoreClient {
// the server and/or tweak certain RPC behaviors.
ClientContext context;
auto stream = stub_->GetValues(&context);
- for (const auto& key:keys) {
+ for (const auto& key : keys) {
// Key we are sending to the server.
Request request;
request.set_key(key);
@@ -61,7 +61,7 @@ class KeyValueStoreClient {
}
stream->WritesDone();
Status status = stream->Finish();
- if(!status.ok()) {
+ if (!status.ok()) {
std::cout << status.error_code() << ": " << status.error_message()
<< std::endl;
std::cout << "RPC failed";
@@ -79,7 +79,7 @@ int main(int argc, char** argv) {
// (use of InsecureChannelCredentials()).
KeyValueStoreClient client(grpc::CreateChannel(
"localhost:50051", grpc::InsecureChannelCredentials()));
- std::vector<std::string> keys = {"key1", "key2", "key3", "key4", "key5"};
+ std::vector<std::string> keys = {"key1", "key2", "key3", "key4", "key5"};
client.GetValues(keys);
return 0;
diff --git a/examples/cpp/keyvaluestore/server.cc b/examples/cpp/keyvaluestore/server.cc
index 515a1ba4c9..e75da9c62d 100644
--- a/examples/cpp/keyvaluestore/server.cc
+++ b/examples/cpp/keyvaluestore/server.cc
@@ -34,9 +34,9 @@ using grpc::ServerBuilder;
using grpc::ServerContext;
using grpc::ServerReaderWriter;
using grpc::Status;
+using keyvaluestore::KeyValueStore;
using keyvaluestore::Request;
using keyvaluestore::Response;
-using keyvaluestore::KeyValueStore;
struct kv_pair {
const char* key;
@@ -44,16 +44,13 @@ struct kv_pair {
};
static const kv_pair kvs_map[] = {
- {"key1", "value1"},
- {"key2", "value2"},
- {"key3", "value3"},
- {"key4", "value4"},
- {"key5", "value5"},
+ {"key1", "value1"}, {"key2", "value2"}, {"key3", "value3"},
+ {"key4", "value4"}, {"key5", "value5"},
};
-const char * get_value_from_map(const char* key) {
- for(size_t i = 0; i < sizeof(kvs_map) / sizeof(kv_pair); ++i) {
- if(strcmp(key, kvs_map[i].key) == 0) {
+const char* get_value_from_map(const char* key) {
+ for (size_t i = 0; i < sizeof(kvs_map) / sizeof(kv_pair); ++i) {
+ if (strcmp(key, kvs_map[i].key) == 0) {
return kvs_map[i].value;
}
}
@@ -62,9 +59,10 @@ const char * get_value_from_map(const char* key) {
// Logic and data behind the server's behavior.
class KeyValueStoreServiceImpl final : public KeyValueStore::Service {
- Status GetValues(ServerContext* context, ServerReaderWriter<Response, Request> *stream) override {
+ Status GetValues(ServerContext* context,
+ ServerReaderWriter<Response, Request>* stream) override {
Request request;
- while(stream->Read(&request)) {
+ while (stream->Read(&request)) {
Response response;
response.set_value(get_value_from_map(request.key().c_str()));
stream->Write(response);