Rename examples/tips to examples/pubsub

pull/509/head
Chen wang 10 years ago
parent bc91e25c3d
commit 842325110d
  1. 127
      Makefile
  2. 30
      build.json
  3. 12
      examples/pubsub/README
  4. 0
      examples/pubsub/empty.proto
  5. 0
      examples/pubsub/label.proto
  6. 10
      examples/pubsub/main.cc
  7. 6
      examples/pubsub/publisher.cc
  8. 12
      examples/pubsub/publisher.h
  9. 6
      examples/pubsub/publisher_test.cc
  10. 4
      examples/pubsub/pubsub.proto
  11. 6
      examples/pubsub/subscriber.cc
  12. 12
      examples/pubsub/subscriber.h
  13. 6
      examples/pubsub/subscriber_test.cc
  14. 4
      tools/run_tests/tests.json

File diff suppressed because one or more lines are too long

@ -460,15 +460,15 @@
] ]
}, },
{ {
"name": "tips_client_lib", "name": "pubsub_client_lib",
"build": "private", "build": "private",
"language": "c++", "language": "c++",
"src": [ "src": [
"examples/tips/label.proto", "examples/pubsub/label.proto",
"examples/tips/empty.proto", "examples/pubsub/empty.proto",
"examples/tips/pubsub.proto", "examples/pubsub/pubsub.proto",
"examples/tips/publisher.cc", "examples/pubsub/publisher.cc",
"examples/tips/subscriber.cc" "examples/pubsub/subscriber.cc"
], ],
"deps": [ "deps": [
"grpc++", "grpc++",
@ -1726,15 +1726,15 @@
] ]
}, },
{ {
"name": "tips_client", "name": "pubsub_client",
"build": "test", "build": "test",
"run": false, "run": false,
"language": "c++", "language": "c++",
"src": [ "src": [
"examples/tips/main.cc" "examples/pubsub/main.cc"
], ],
"deps": [ "deps": [
"tips_client_lib", "pubsub_client_lib",
"grpc++_test_util", "grpc++_test_util",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
@ -1744,14 +1744,14 @@
] ]
}, },
{ {
"name": "tips_publisher_test", "name": "pubsub_publisher_test",
"build": "test", "build": "test",
"language": "c++", "language": "c++",
"src": [ "src": [
"examples/tips/publisher_test.cc" "examples/pubsub/publisher_test.cc"
], ],
"deps": [ "deps": [
"tips_client_lib", "pubsub_client_lib",
"grpc++_test_util", "grpc++_test_util",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
@ -1761,14 +1761,14 @@
] ]
}, },
{ {
"name": "tips_subscriber_test", "name": "pubsub_subscriber_test",
"build": "test", "build": "test",
"language": "c++", "language": "c++",
"src": [ "src": [
"examples/tips/subscriber_test.cc" "examples/pubsub/subscriber_test.cc"
], ],
"deps": [ "deps": [
"tips_client_lib", "pubsub_client_lib",
"grpc++_test_util", "grpc++_test_util",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",

@ -1,4 +1,4 @@
C++ Client implementation for Cloud Pub/Sub service (TIPS) C++ Client implementation for Cloud Pub/Sub service
(https://developers.google.com/apis-explorer/#p/pubsub/v1beta1/). (https://developers.google.com/apis-explorer/#p/pubsub/v1beta1/).
"Google Cloud Pub/Sub" API needs to be enabled at "Google Cloud Pub/Sub" API needs to be enabled at
@ -12,15 +12,19 @@ be created with scope "https://www.googleapis.com/auth/cloud-platform" as below:
gcloud compute instances create instance-name gcloud compute instances create instance-name
--image debian-7 --scopes https://www.googleapis.com/auth/cloud-platform --image debian-7 --scopes https://www.googleapis.com/auth/cloud-platform
Google TLS cert is required to run the client, which can be downloaded from
Chrome browser.
To run the client from GCE: To run the client from GCE:
make tips_client make pubsub_client
bins/opt/tips_client --project_id="your project id" GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="Google TLS cert" bins/opt/pubsub_client
--project_id="your project id"
A service account credential is required to run the client from other A service account credential is required to run the client from other
environments, which can be generated as a JSON key file from environments, which can be generated as a JSON key file from
https://console.developers.google.com/project/. To run the client with a service https://console.developers.google.com/project/. To run the client with a service
account credential: account credential:
bins/opt/tips_client GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="Google TLS cert" bins/opt/pubsub_client
--project_id="your project id" --project_id="your project id"
--service_account_key_file="absolute path to the JSON key file" --service_account_key_file="absolute path to the JSON key file"

@ -46,8 +46,8 @@
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/status.h> #include <grpc++/status.h>
#include "examples/tips/publisher.h" #include "examples/pubsub/publisher.h"
#include "examples/tips/subscriber.h" #include "examples/pubsub/subscriber.h"
#include "test/cpp/util/create_test_channel.h" #include "test/cpp/util/create_test_channel.h"
DEFINE_int32(server_port, 443, "Server port."); DEFINE_int32(server_port, 443, "Server port.");
@ -82,7 +82,7 @@ grpc::string GetServiceAccountJsonKey() {
int main(int argc, char** argv) { int main(int argc, char** argv) {
grpc_init(); grpc_init();
google::ParseCommandLineFlags(&argc, &argv, true); google::ParseCommandLineFlags(&argc, &argv, true);
gpr_log(GPR_INFO, "Start TIPS client"); gpr_log(GPR_INFO, "Start PUBSUB client");
std::ostringstream ss; std::ostringstream ss;
@ -104,8 +104,8 @@ int main(int argc, char** argv) {
true, // use prod roots true, // use prod roots
creds)); creds));
grpc::examples::tips::Publisher publisher(channel); grpc::examples::pubsub::Publisher publisher(channel);
grpc::examples::tips::Subscriber subscriber(channel); grpc::examples::pubsub::Subscriber subscriber(channel);
GPR_ASSERT(FLAGS_project_id != ""); GPR_ASSERT(FLAGS_project_id != "");
ss.str(""); ss.str("");

@ -35,7 +35,7 @@
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include "examples/tips/publisher.h" #include "examples/pubsub/publisher.h"
using tech::pubsub::Topic; using tech::pubsub::Topic;
using tech::pubsub::DeleteTopicRequest; using tech::pubsub::DeleteTopicRequest;
@ -48,7 +48,7 @@ using tech::pubsub::PubsubMessage;
namespace grpc { namespace grpc {
namespace examples { namespace examples {
namespace tips { namespace pubsub {
Publisher::Publisher(std::shared_ptr<ChannelInterface> channel) Publisher::Publisher(std::shared_ptr<ChannelInterface> channel)
: stub_(PublisherService::NewStub(channel)) { : stub_(PublisherService::NewStub(channel)) {
@ -119,6 +119,6 @@ Status Publisher::Publish(const grpc::string& topic, const grpc::string& data) {
return stub_->Publish(&context, request, &response); return stub_->Publish(&context, request, &response);
} }
} // namespace tips } // namespace pubsub
} // namespace examples } // namespace examples
} // namespace grpc } // namespace grpc

@ -31,17 +31,17 @@
* *
*/ */
#ifndef __GRPCPP_EXAMPLES_TIPS_PUBLISHER_H_ #ifndef __GRPCPP_EXAMPLES_PUBSUB_PUBLISHER_H_
#define __GRPCPP_EXAMPLES_TIPS_PUBLISHER_H_ #define __GRPCPP_EXAMPLES_PUBSUB_PUBLISHER_H_
#include <grpc++/channel_interface.h> #include <grpc++/channel_interface.h>
#include <grpc++/status.h> #include <grpc++/status.h>
#include "examples/tips/pubsub.pb.h" #include "examples/pubsub/pubsub.pb.h"
namespace grpc { namespace grpc {
namespace examples { namespace examples {
namespace tips { namespace pubsub {
class Publisher { class Publisher {
public: public:
@ -60,8 +60,8 @@ class Publisher {
std::unique_ptr<tech::pubsub::PublisherService::Stub> stub_; std::unique_ptr<tech::pubsub::PublisherService::Stub> stub_;
}; };
} // namespace tips } // namespace pubsub
} // namespace examples } // namespace examples
} // namespace grpc } // namespace grpc
#endif // __GRPCPP_EXAMPLES_TIPS_PUBLISHER_H_ #endif // __GRPCPP_EXAMPLES_PUBSUB_PUBLISHER_H_

@ -43,7 +43,7 @@
#include <grpc++/status.h> #include <grpc++/status.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "examples/tips/publisher.h" #include "examples/pubsub/publisher.h"
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
@ -112,7 +112,7 @@ class PublisherTest : public ::testing::Test {
channel_ = CreateChannel(server_address_.str(), ChannelArguments()); channel_ = CreateChannel(server_address_.str(), ChannelArguments());
publisher_.reset(new grpc::examples::tips::Publisher(channel_)); publisher_.reset(new grpc::examples::pubsub::Publisher(channel_));
} }
void TearDown() override { void TearDown() override {
@ -126,7 +126,7 @@ class PublisherTest : public ::testing::Test {
std::shared_ptr<ChannelInterface> channel_; std::shared_ptr<ChannelInterface> channel_;
std::unique_ptr<grpc::examples::tips::Publisher> publisher_; std::unique_ptr<grpc::examples::pubsub::Publisher> publisher_;
}; };
TEST_F(PublisherTest, TestPublisher) { TEST_F(PublisherTest, TestPublisher) {

@ -4,8 +4,8 @@
syntax = "proto2"; syntax = "proto2";
import "examples/tips/empty.proto"; import "examples/pubsub/empty.proto";
import "examples/tips/label.proto"; import "examples/pubsub/label.proto";
package tech.pubsub; package tech.pubsub;

@ -33,7 +33,7 @@
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include "examples/tips/subscriber.h" #include "examples/pubsub/subscriber.h"
using tech::pubsub::Topic; using tech::pubsub::Topic;
using tech::pubsub::DeleteTopicRequest; using tech::pubsub::DeleteTopicRequest;
@ -46,7 +46,7 @@ using tech::pubsub::PubsubMessage;
namespace grpc { namespace grpc {
namespace examples { namespace examples {
namespace tips { namespace pubsub {
Subscriber::Subscriber(std::shared_ptr<ChannelInterface> channel) Subscriber::Subscriber(std::shared_ptr<ChannelInterface> channel)
: stub_(SubscriberService::NewStub(channel)) { : stub_(SubscriberService::NewStub(channel)) {
@ -113,6 +113,6 @@ Status Subscriber::Pull(const grpc::string& name, grpc::string* data) {
return s; return s;
} }
} // namespace tips } // namespace pubsub
} // namespace examples } // namespace examples
} // namespace grpc } // namespace grpc

@ -31,17 +31,17 @@
* *
*/ */
#ifndef __GRPCPP_EXAMPLES_TIPS_SUBSCRIBER_H_ #ifndef __GRPCPP_EXAMPLES_PUBSUB_SUBSCRIBER_H_
#define __GRPCPP_EXAMPLES_TIPS_SUBSCRIBER_H_ #define __GRPCPP_EXAMPLES_PUBSUB_SUBSCRIBER_H_
#include <grpc++/channel_interface.h> #include <grpc++/channel_interface.h>
#include <grpc++/status.h> #include <grpc++/status.h>
#include "examples/tips/pubsub.pb.h" #include "examples/pubsub/pubsub.pb.h"
namespace grpc { namespace grpc {
namespace examples { namespace examples {
namespace tips { namespace pubsub {
class Subscriber { class Subscriber {
public: public:
@ -61,8 +61,8 @@ class Subscriber {
std::unique_ptr<tech::pubsub::SubscriberService::Stub> stub_; std::unique_ptr<tech::pubsub::SubscriberService::Stub> stub_;
}; };
} // namespace tips } // namespace pubsub
} // namespace examples } // namespace examples
} // namespace grpc } // namespace grpc
#endif // __GRPCPP_EXAMPLES_TIPS_SUBSCRIBER_H_ #endif // __GRPCPP_EXAMPLES_PUBSUB_SUBSCRIBER_H_

@ -43,7 +43,7 @@
#include <grpc++/status.h> #include <grpc++/status.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "examples/tips/subscriber.h" #include "examples/pubsub/subscriber.h"
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
@ -111,7 +111,7 @@ class SubscriberTest : public ::testing::Test {
channel_ = CreateChannel(server_address_.str(), ChannelArguments()); channel_ = CreateChannel(server_address_.str(), ChannelArguments());
subscriber_.reset(new grpc::examples::tips::Subscriber(channel_)); subscriber_.reset(new grpc::examples::pubsub::Subscriber(channel_));
} }
void TearDown() override { void TearDown() override {
@ -125,7 +125,7 @@ class SubscriberTest : public ::testing::Test {
std::shared_ptr<ChannelInterface> channel_; std::shared_ptr<ChannelInterface> channel_;
std::unique_ptr<grpc::examples::tips::Subscriber> subscriber_; std::unique_ptr<grpc::examples::pubsub::Subscriber> subscriber_;
}; };
TEST_F(SubscriberTest, TestSubscriber) { TEST_F(SubscriberTest, TestSubscriber) {

@ -291,11 +291,11 @@
}, },
{ {
"language": "c++", "language": "c++",
"name": "tips_publisher_test" "name": "pubsub_publisher_test"
}, },
{ {
"language": "c++", "language": "c++",
"name": "tips_subscriber_test" "name": "pubsub_subscriber_test"
}, },
{ {
"language": "c", "language": "c",

Loading…
Cancel
Save