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",
"language": "c++",
"src": [
"examples/tips/label.proto",
"examples/tips/empty.proto",
"examples/tips/pubsub.proto",
"examples/tips/publisher.cc",
"examples/tips/subscriber.cc"
"examples/pubsub/label.proto",
"examples/pubsub/empty.proto",
"examples/pubsub/pubsub.proto",
"examples/pubsub/publisher.cc",
"examples/pubsub/subscriber.cc"
],
"deps": [
"grpc++",
@ -1726,15 +1726,15 @@
]
},
{
"name": "tips_client",
"name": "pubsub_client",
"build": "test",
"run": false,
"language": "c++",
"src": [
"examples/tips/main.cc"
"examples/pubsub/main.cc"
],
"deps": [
"tips_client_lib",
"pubsub_client_lib",
"grpc++_test_util",
"grpc_test_util",
"grpc++",
@ -1744,14 +1744,14 @@
]
},
{
"name": "tips_publisher_test",
"name": "pubsub_publisher_test",
"build": "test",
"language": "c++",
"src": [
"examples/tips/publisher_test.cc"
"examples/pubsub/publisher_test.cc"
],
"deps": [
"tips_client_lib",
"pubsub_client_lib",
"grpc++_test_util",
"grpc_test_util",
"grpc++",
@ -1761,14 +1761,14 @@
]
},
{
"name": "tips_subscriber_test",
"name": "pubsub_subscriber_test",
"build": "test",
"language": "c++",
"src": [
"examples/tips/subscriber_test.cc"
"examples/pubsub/subscriber_test.cc"
],
"deps": [
"tips_client_lib",
"pubsub_client_lib",
"grpc++_test_util",
"grpc_test_util",
"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/).
"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
--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:
make tips_client
bins/opt/tips_client --project_id="your project id"
make pubsub_client
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
environments, which can be generated as a JSON key file from
https://console.developers.google.com/project/. To run the client with a service
account credential:
bins/opt/tips_client
GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="Google TLS cert" bins/opt/pubsub_client
--project_id="your project id"
--service_account_key_file="absolute path to the JSON key file"

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

@ -35,7 +35,7 @@
#include <grpc++/client_context.h>
#include "examples/tips/publisher.h"
#include "examples/pubsub/publisher.h"
using tech::pubsub::Topic;
using tech::pubsub::DeleteTopicRequest;
@ -48,7 +48,7 @@ using tech::pubsub::PubsubMessage;
namespace grpc {
namespace examples {
namespace tips {
namespace pubsub {
Publisher::Publisher(std::shared_ptr<ChannelInterface> 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);
}
} // namespace tips
} // namespace pubsub
} // namespace examples
} // namespace grpc

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

@ -43,7 +43,7 @@
#include <grpc++/status.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/test_config.h"
@ -112,7 +112,7 @@ class PublisherTest : public ::testing::Test {
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 {
@ -126,7 +126,7 @@ class PublisherTest : public ::testing::Test {
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) {

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

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

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

@ -43,7 +43,7 @@
#include <grpc++/status.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/test_config.h"
@ -111,7 +111,7 @@ class SubscriberTest : public ::testing::Test {
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 {
@ -125,7 +125,7 @@ class SubscriberTest : public ::testing::Test {
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) {

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

Loading…
Cancel
Save