md_doc_command_line_tool.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.6"/>
  7. <title>GRPC Core: gRPC command line tool</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  12. <script type="text/javascript" src="search/search.js"></script>
  13. <script type="text/javascript">
  14. $(document).ready(function() { searchBox.OnSelectItem(0); });
  15. </script>
  16. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  17. </head>
  18. <body>
  19. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  20. <div id="titlearea">
  21. <table cellspacing="0" cellpadding="0">
  22. <tbody>
  23. <tr style="height: 56px;">
  24. <td style="padding-left: 0.5em;">
  25. <div id="projectname">GRPC Core
  26. &#160;<span id="projectnumber">4.0.0</span>
  27. </div>
  28. </td>
  29. </tr>
  30. </tbody>
  31. </table>
  32. </div>
  33. <!-- end header part -->
  34. <!-- Generated by Doxygen 1.8.6 -->
  35. <script type="text/javascript">
  36. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  37. </script>
  38. <div id="navrow1" class="tabs">
  39. <ul class="tablist">
  40. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  41. <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  42. <li><a href="modules.html"><span>Modules</span></a></li>
  43. <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
  44. <li><a href="files.html"><span>Files</span></a></li>
  45. <li>
  46. <div id="MSearchBox" class="MSearchBoxInactive">
  47. <span class="left">
  48. <img id="MSearchSelect" src="search/mag_sel.png"
  49. onmouseover="return searchBox.OnSearchSelectShow()"
  50. onmouseout="return searchBox.OnSearchSelectHide()"
  51. alt=""/>
  52. <input type="text" id="MSearchField" value="Search" accesskey="S"
  53. onfocus="searchBox.OnSearchFieldFocus(true)"
  54. onblur="searchBox.OnSearchFieldFocus(false)"
  55. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  56. </span><span class="right">
  57. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  58. </span>
  59. </div>
  60. </li>
  61. </ul>
  62. </div>
  63. <!-- window showing the filter options -->
  64. <div id="MSearchSelectWindow"
  65. onmouseover="return searchBox.OnSearchSelectShow()"
  66. onmouseout="return searchBox.OnSearchSelectHide()"
  67. onkeydown="return searchBox.OnSearchSelectKey(event)">
  68. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>
  69. <!-- iframe showing the search results (closed by default) -->
  70. <div id="MSearchResultsWindow">
  71. <iframe src="javascript:void(0)" frameborder="0"
  72. name="MSearchResults" id="MSearchResults">
  73. </iframe>
  74. </div>
  75. </div><!-- top -->
  76. <div class="header">
  77. <div class="headertitle">
  78. <div class="title">gRPC command line tool </div> </div>
  79. </div><!--header-->
  80. <div class="contents">
  81. <div class="textblock"><h2>Overview</h2>
  82. <p>This document describes the command line tool that comes with gRPC repository. It is desirable to have command line tools written in other languages roughly follow the same syntax and flags.</p>
  83. <p>At this point, the tool needs to be built from source, and it should be moved out to grpc-tools repository as a stand alone application once it is mature enough.</p>
  84. <h2>Core functionality</h2>
  85. <p>The command line tool can do the following things:</p>
  86. <ul>
  87. <li>Send unary rpc.</li>
  88. <li>Attach metadata and display received metadata.</li>
  89. <li>Handle common authentication to server.</li>
  90. <li>Infer request/response types from server reflection result.</li>
  91. <li>Find the request/response types from a given proto file.</li>
  92. <li>Read proto request in text form.</li>
  93. <li>Read request in wire form (for protobuf messages, this means serialized binary form).</li>
  94. <li>Display proto response in text form.</li>
  95. <li>Write response in wire form to a file.</li>
  96. </ul>
  97. <p>The command line tool should support the following things:</p>
  98. <ul>
  99. <li>List server services and methods through server reflection.</li>
  100. <li>Fine-grained auth control (such as, use this oauth token to talk to the server).</li>
  101. <li>Send streaming rpc.</li>
  102. </ul>
  103. <h2>Code location</h2>
  104. <p>To use the tool, you need to get the grpc repository and make sure your system has the prerequisites for building grpc from source, given in the https://github.com/grpc/grpc/blob/master/INSTALL.md "installation
  105. instructions".</p>
  106. <p>In order to build the grpc command line tool from a fresh clone of the grpc repository, you need to run the following command to update submodules:</p>
  107. <p>``` git submodule update &ndash;init ```</p>
  108. <p>You also need to have the gflags library installed on your system. On Linux systems, gflags can be installed with the following command:</p>
  109. <p>``` sudo apt-get install libgflags-dev ```</p>
  110. <p>Once the prerequisites are satisfied, you can build the command line tool with the command:</p>
  111. <p>``` $ make grpc_cli ```</p>
  112. <p>The main file can be found at <a href="https://github.com/grpc/grpc/blob/master/test/cpp/util/grpc_cli.cc">https://github.com/grpc/grpc/blob/master/test/cpp/util/grpc_cli.cc</a></p>
  113. <h2>Usage</h2>
  114. <h3>Basic usage</h3>
  115. <p>Send a rpc to a helloworld server at <code>localhost:50051</code>:</p>
  116. <p>``` $ bins/opt/grpc_cli call localhost:50051 SayHello "name: 'world'" \ &ndash;enable_ssl=false ```</p>
  117. <p>On success, the tool will print out</p>
  118. <p>``` Rpc succeeded with OK status Response: message: "Hello world" ```</p>
  119. <p>The <code>localhost:50051</code> part indicates the server you are connecting to. <code>SayHello</code> is (part of) the gRPC method string. Then `"name: 'world'"<code>is the text format of the request proto message. We are not using ssl here by</code>&ndash;enable_ssl=false<code>. For information on more flags, look at the comments of</code>grpc_cli.cc`.</p>
  120. <h3>Use local proto files</h3>
  121. <p>If the server does not have the server reflection service, you will need to provide local proto files containing the service definition. The tool will try to find request/response types from them.</p>
  122. <p>``` $ bins/opt/grpc_cli call localhost:50051 SayHello "name: 'world'" \ &ndash;protofiles=examples/protos/helloworld.proto &ndash;enable_ssl=false ```</p>
  123. <p>If the proto files is not under current directory, you can use <code>--proto_path</code> to specify a new search root.</p>
  124. <h3>Send non-proto rpc</h3>
  125. <p>For using gRPC with protocols other than probobuf, you will need the exact method name string and a file containing the raw bytes to be sent on the wire</p>
  126. <p>``` $ bins/opt/grpc_cli call localhost:50051 /helloworld.Greeter/SayHello &ndash;input_binary_file=input.bin \ &ndash;output_binary_file=output.bin ``<code> On success, you will need to read or decode the response from the</code>output.bin` file. </p>
  127. </div></div><!-- contents -->
  128. <!-- start footer part -->
  129. <hr class="footer"/><address class="footer"><small>
  130. Generated on Wed Jun 21 2017 14:13:07 for GRPC Core by &#160;<a href="http://www.doxygen.org/index.html">
  131. <img class="footer" src="doxygen.png" alt="doxygen"/>
  132. </a> 1.8.6
  133. </small></address>
  134. </body>
  135. </html>