blob: ae012c25604d967074a3fabb72b8b467533e2574 [file] [log] [blame]
Yang Gaoa5e20d32015-03-25 09:55:20 -07001/*
2 *
3 * Copyright 2015, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#include <chrono>
35#include <iostream>
36#include <thread>
37
38#include "test/cpp/util/create_test_channel.h"
39#include "src/cpp/util/time.h"
40#include "src/cpp/server/thread_pool.h"
41#include <gflags/gflags.h>
42#include <grpc++/channel_arguments.h>
43#include <grpc++/channel_interface.h>
44#include <grpc++/client_context.h>
45#include <grpc++/create_channel.h>
46#include <grpc++/credentials.h>
47#include <grpc++/server.h>
48#include <grpc++/server_builder.h>
49#include <grpc++/server_context.h>
50#include <grpc++/server_credentials.h>
51#include <grpc++/status.h>
52#include <grpc++/stream.h>
53#include "test/core/util/port.h"
54
55#include <grpc/grpc.h>
56#include <grpc/support/thd.h>
57#include <grpc/support/time.h>
58
59// In some distros, gflags is in the namespace google, and in some others,
60// in gflags. This hack is enabling us to find both.
61namespace google { }
62namespace gflags { }
63using namespace google;
64using namespace gflags;
65
66using std::chrono::system_clock;
67
68// DEFINE_bool(enable_ssl, true, "Whether to use ssl/tls.");
69
70void Call() {}
71
72int main(int argc, char** argv) {
73 grpc_init();
74
75 ParseCommandLineFlags(&argc, &argv, true);
76
77 if (argc < grpc::string(argv[1]) != "call") {
78 std::cout << "Usage: grpc_cli call server_host:port full_method_string\n"
79 << "Example: grpc_cli call service.googleapis.com "
80 << "/grpc.cpp.test.util.TestService/Echo " << std::endl;
81 }
82 grpc::string server_address(argv[2]);
83 grpc::string method(argv[3]);
84 std::cout << "connecting to " << server_address << std::endl;
85 std::cout << "method is " << method << std::endl;
86
87 std::unique_ptr<grpc::Credentials> creds = grpc::GoogleDefaultCredentials();
88 std::shared_ptr<grpc::ChannelInterface> channel =
89 grpc::CreateChannel(server_address, creds, grpc::ChannelArguments());
90
91 // Parse argument
92 Call();
93
94 channel.reset();
95 grpc_shutdown();
96 return 0;
97}
98
99
100