Update docs

pull/7269/head
Yuchen Zeng 9 years ago
parent 256cc7aa03
commit c24e0ee4f0
  1. 21
      test/cpp/util/grpc_cli.cc
  2. 7
      test/cpp/util/proto_file_parser.cc

@ -34,18 +34,21 @@
/* /*
A command line tool to talk to a grpc server. A command line tool to talk to a grpc server.
Example of talking to grpc interop server: Example of talking to grpc interop server:
grpc_cli call localhost:50051 UnaryCall src/proto/grpc/testing/test.proto \ grpc_cli call localhost:50051 UnaryCall "response_size:10" \
"response_size:10" --enable_ssl=false --proto_file=src/proto/grpc/testing/test.prot --enable_ssl=false
Options: Options:
1. --proto_path, if your proto file is not under current working directory, 1. --proto_file, use this flag to provide a proto file if the server does
does not have the reflection service.
2. --proto_path, if your proto file is not under current working directory,
use this flag to provide a search root. It should work similar to the use this flag to provide a search root. It should work similar to the
counterpart in protoc. counterpart in protoc. This option is valid only when proto_file is
2. --metadata specifies metadata to be sent to the server, such as: provided.
3. --metadata specifies metadata to be sent to the server, such as:
--metadata="MyHeaderKey1:Value1:MyHeaderKey2:Value2" --metadata="MyHeaderKey1:Value1:MyHeaderKey2:Value2"
3. --enable_ssl, whether to use tls. 4. --enable_ssl, whether to use tls.
4. --use_auth, if set to true, attach a GoogleDefaultCredentials to the call 5. --use_auth, if set to true, attach a GoogleDefaultCredentials to the call
3. --input_binary_file, a file containing the serialized request. The file 6. --input_binary_file, a file containing the serialized request. The file
can be generated by calling something like: can be generated by calling something like:
protoc --proto_path=src/proto/grpc/testing/ \ protoc --proto_path=src/proto/grpc/testing/ \
--encode=grpc.testing.SimpleRequest \ --encode=grpc.testing.SimpleRequest \
@ -53,7 +56,7 @@
< input.txt > input.bin < input.txt > input.bin
If this is used and no proto file is provided in the argument list, the If this is used and no proto file is provided in the argument list, the
method string has to be exact in the form of /package.service/method. method string has to be exact in the form of /package.service/method.
4. --output_binary_file, a file to write binary format response into, it can 7. --output_binary_file, a file to write binary format response into, it can
be later decoded using protoc: be later decoded using protoc:
protoc --proto_path=src/proto/grpc/testing/ \ protoc --proto_path=src/proto/grpc/testing/ \
--decode=grpc.testing.SimpleResponse \ --decode=grpc.testing.SimpleResponse \

@ -109,7 +109,10 @@ ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel,
desc_pool_(new google::protobuf::DescriptorPool(desc_db_.get())) { desc_pool_(new google::protobuf::DescriptorPool(desc_db_.get())) {
std::vector<std::string> service_list; std::vector<std::string> service_list;
if (!desc_db_->GetServices(&service_list)) { if (!desc_db_->GetServices(&service_list)) {
LogError("Failed to get services"); LogError(
"Failed to get services from the server, "
"it may not have the reflection service.\n"
"Please try to use the --proto_file option to provide a proto file.");
} }
if (has_error_) { if (has_error_) {
return; return;
@ -177,7 +180,7 @@ grpc::string ProtoFileParser::GetSerializedProto(
LogError("Failed to parse text format to proto."); LogError("Failed to parse text format to proto.");
return ""; return "";
} }
ok = request_prototype_->SerializeToString(&serialized); ok = msg->SerializeToString(&serialized);
if (!ok) { if (!ok) {
LogError("Failed to serialize proto."); LogError("Failed to serialize proto.");
return ""; return "";

Loading…
Cancel
Save