|
|
|
@ -31,40 +31,26 @@ |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <chrono> |
|
|
|
|
#include <memory> |
|
|
|
|
#include <string> |
|
|
|
|
#include <thread> |
|
|
|
|
|
|
|
|
|
#include <grpc/grpc.h> |
|
|
|
|
#include <grpc/support/log.h> |
|
|
|
|
#include <google/gflags.h> |
|
|
|
|
#include <grpc++/channel_arguments.h> |
|
|
|
|
#include <grpc++/channel_interface.h> |
|
|
|
|
#include <grpc++/client_context.h> |
|
|
|
|
#include <grpc++/create_channel.h> |
|
|
|
|
#include <grpc++/status.h> |
|
|
|
|
#include <grpc++/stream.h> |
|
|
|
|
|
|
|
|
|
#include "examples/tips/client.h" |
|
|
|
|
#include "test/cpp/util/create_test_channel.h" |
|
|
|
|
|
|
|
|
|
DEFINE_bool(enable_ssl, false, "Whether to use ssl/tls."); |
|
|
|
|
DEFINE_bool(use_prod_roots, false, "True to use SSL roots for production GFE"); |
|
|
|
|
DEFINE_bool(enable_ssl, true, "Whether to use ssl/tls."); |
|
|
|
|
DEFINE_bool(use_prod_roots, true, "True to use SSL roots for production GFE"); |
|
|
|
|
DEFINE_int32(server_port, 0, "Server port."); |
|
|
|
|
DEFINE_string(server_host, "127.0.0.1", "Server host to connect to"); |
|
|
|
|
DEFINE_string(server_host_override, "foo.test.google.com", |
|
|
|
|
"Override the server host which is sent in HTTP header"); |
|
|
|
|
|
|
|
|
|
using grpc::ChannelInterface; |
|
|
|
|
using grpc::ClientContext; |
|
|
|
|
using grpc::CreateTestChannel; |
|
|
|
|
|
|
|
|
|
void CreateTopic(std::shared_ptr<ChannelInterface> channel, grpc::string topic); |
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) { |
|
|
|
|
grpc_init(); |
|
|
|
|
|
|
|
|
|
google::ParseCommandLineFlags(&argc, &argv, true); |
|
|
|
|
|
|
|
|
|
gpr_log(GPR_INFO, "Start TIPS client"); |
|
|
|
|
|
|
|
|
|
GPR_ASSERT(FLAGS_server_port); |
|
|
|
@ -73,11 +59,13 @@ int main(int argc, char** argv) { |
|
|
|
|
snprintf(host_port, host_port_buf_size, "%s:%d", FLAGS_server_host.c_str(), |
|
|
|
|
FLAGS_server_port); |
|
|
|
|
|
|
|
|
|
std::shared_ptr<ChannelInterface> channel( |
|
|
|
|
CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_enable_ssl, |
|
|
|
|
FLAGS_use_prod_roots)); |
|
|
|
|
std::shared_ptr<grpc::ChannelInterface> channel( |
|
|
|
|
grpc::CreateTestChannel(host_port, FLAGS_server_host_override, |
|
|
|
|
FLAGS_enable_ssl, FLAGS_use_prod_roots)); |
|
|
|
|
|
|
|
|
|
CreateTopic(channel, "test"); |
|
|
|
|
grpc::examples::tips::Client client(channel); |
|
|
|
|
grpc::Status s = client.CreateTopic("test"); |
|
|
|
|
GPR_ASSERT(s.IsOk()); |
|
|
|
|
|
|
|
|
|
channel.reset(); |
|
|
|
|
grpc_shutdown(); |
|
|
|
|