diff options
author | 2015-01-28 17:51:32 -0800 | |
---|---|---|
committer | 2015-01-28 17:51:32 -0800 | |
commit | 3cc1ad62b6a41a1369e83724014f447945ac479a (patch) | |
tree | 996f6348af665c922ab9748a98176674957ca8c3 | |
parent | 862e23c662b5adc0781f0e504fc5a071ac60fb22 (diff) |
add more tips ops
-rw-r--r-- | examples/tips/client.cc | 32 | ||||
-rw-r--r-- | examples/tips/client.h | 3 | ||||
-rw-r--r-- | examples/tips/client_main.cc | 13 |
3 files changed, 46 insertions, 2 deletions
diff --git a/examples/tips/client.cc b/examples/tips/client.cc index 695ff80e8a..f9d53197ed 100644 --- a/examples/tips/client.cc +++ b/examples/tips/client.cc @@ -36,7 +36,11 @@ #include "examples/tips/client.h" using tech::pubsub::Topic; +using tech::pubsub::DeleteTopicRequest; +using tech::pubsub::GetTopicRequest; using tech::pubsub::PublisherService; +using tech::pubsub::ListTopicsRequest; +using tech::pubsub::ListTopicsResponse; namespace grpc { namespace examples { @@ -55,6 +59,34 @@ Status Client::CreateTopic(grpc::string topic) { return stub_->CreateTopic(&context, request, &response); } +Status Client::ListTopics() { + ListTopicsRequest request; + ListTopicsResponse response; + ClientContext context; + + return stub_->ListTopics(&context, request, &response); +} + +Status Client::GetTopic(grpc::string topic) { + GetTopicRequest request; + Topic response; + ClientContext context; + + request.set_topic(topic); + + return stub_->GetTopic(&context, request, &response); +} + +Status Client::DeleteTopic(grpc::string topic) { + DeleteTopicRequest request; + proto2::Empty response; + ClientContext context; + + request.set_topic(topic); + + return stub_->DeleteTopic(&context, request, &response); +} + } // namespace tips } // namespace examples } // namespace grpc diff --git a/examples/tips/client.h b/examples/tips/client.h index 6ae9d50658..661ee5c4af 100644 --- a/examples/tips/client.h +++ b/examples/tips/client.h @@ -47,6 +47,9 @@ class Client { public: Client(std::shared_ptr<grpc::ChannelInterface> channel); Status CreateTopic(grpc::string topic); + Status GetTopic(grpc::string topic); + Status DeleteTopic(grpc::string topic); + Status ListTopics(); private: std::unique_ptr<tech::pubsub::PublisherService::Stub> stub_; diff --git a/examples/tips/client_main.cc b/examples/tips/client_main.cc index b4adde2836..041dbd5770 100644 --- a/examples/tips/client_main.cc +++ b/examples/tips/client_main.cc @@ -97,8 +97,17 @@ int main(int argc, char** argv) { creds)); grpc::examples::tips::Client client(channel); - grpc::Status s = client.CreateTopic("test"); - gpr_log(GPR_INFO, "return code %d", s.code()); + + grpc::Status s = client.CreateTopic("/topics/stoked-keyword-656/testtopics"); + gpr_log(GPR_INFO, "return code %d, %s", s.code(), s.details().c_str()); + GPR_ASSERT(s.IsOk()); + + s = client.GetTopic("/topics/stoked-keyword-656/testtopics"); + gpr_log(GPR_INFO, "return code %d, %s", s.code(), s.details().c_str()); + GPR_ASSERT(s.IsOk()); + + s = client.DeleteTopic("/topics/stoked-keyword-656/testtopics"); + gpr_log(GPR_INFO, "return code %d, %s", s.code(), s.details().c_str()); GPR_ASSERT(s.IsOk()); channel.reset(); |