md_doc_service_config.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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: Service Config in gRPC</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">Service Config in gRPC </div> </div>
  79. </div><!--header-->
  80. <div class="contents">
  81. <div class="textblock"><h1>Objective</h1>
  82. <p>The service config is a mechanism that allows service owners to publish parameters to be automatically used by all clients of their service.</p>
  83. <h1>Format</h1>
  84. <p>The service config is a JSON string of the following form:</p>
  85. <p>``` { // Load balancing policy name. // Currently, the only selectable client-side policy provided with gRPC // is 'round_robin', but third parties may add their own policies. // This field is optional; if unset, the default behavior is to pick // the first available backend. // If the policy name is set via the client API, that value overrides // the value specified here. // // Note that if the resolver returns at least one balancer address (as // opposed to backend addresses), gRPC will use grpclb (see // <a href="https://github.com/grpc/grpc/blob/master/doc/load-balancing.md">https://github.com/grpc/grpc/blob/master/doc/load-balancing.md</a>), // regardless of what LB policy is requested either here or via the // client API. However, if the resolver returns at least one backend // address in addition to the balancer address(es), the client may fall // back to the requested policy if it is unable to reach any of the // grpclb load balancers. 'loadBalancingPolicy': string,</p>
  86. <p>// Per-method configuration. Optional. 'methodConfig': [ { // The names of the methods to which this method config applies. There // must be at least one name. Each name entry must be unique across the // entire service config. If the 'method' field is empty, then this // method config specifies the defaults for all methods for the specified // service. // // For example, let's say that the service config contains the following // method config entries: // // 'methodConfig': [ // { 'name': [ { 'service': 'MyService' } ] ... }, // { 'name': [ { 'service': 'MyService', 'method': 'Foo' } ] ... } // ] // // For a request for MyService/Foo, we will use the second entry, because // it exactly matches the service and method name. // For a request for MyService/Bar, we will use the first entry, because // it provides the default for all methods of MyService. 'name': [ { // RPC service name. Required. // If using gRPC with protobuf as the IDL, then this will be of // the form "pkg.service_name", where "pkg" is the package name // defined in the proto file. 'service': string,</p>
  87. <p>// RPC method name. Optional (see above). 'method': string, } ],</p>
  88. <p>// Whether RPCs sent to this method should wait until the connection is // ready by default. If false, the RPC will abort immediately if there // is a transient failure connecting to the server. Otherwise, gRPC will // attempt to connect until the deadline is exceeded. // // The value specified via the gRPC client API will override the value // set here. However, note that setting the value in the client API will // also affect transient errors encountered during name resolution, // which cannot be caught by the value here, since the service config // is obtained by the gRPC client via name resolution. 'waitForReady': bool,</p>
  89. <p>// The default timeout in seconds for RPCs sent to this method. This can // be overridden in code. If no reply is received in the specified amount // of time, the request is aborted and a deadline-exceeded error status // is returned to the caller. // // The actual deadline used will be the minimum of the value specified // here and the value set by the application via the gRPC client API. // If either one is not set, then the other will be used. // If neither is set, then the request has no deadline. // // The format of the value is that of the 'Duration' type defined here: // <a href="https://developers.google.com/protocol-buffers/docs/proto3#json">https://developers.google.com/protocol-buffers/docs/proto3#json</a> 'timeout': string,</p>
  90. <p>// The maximum allowed payload size for an individual request or object // in a stream (client-&gt;server) in bytes. The size which is measured is // the serialized, uncompressed payload in bytes. This applies both // to streaming and non-streaming requests. // // The actual value used is the minimum of the value specified here and // the value set by the application via the gRPC client API. // If either one is not set, then the other will be used. // If neither is set, then the built-in default is used. // // If a client attempts to send an object larger than this value, it // will not be sent and the client will see an error. // Note that 0 is a valid value, meaning that the request message must // be empty. 'maxRequestMessageBytes': number,</p>
  91. <p>// The maximum allowed payload size for an individual response or object // in a stream (server-&gt;client) in bytes. The size which is measured is // the serialized, uncompressed payload in bytes. This applies both // to streaming and non-streaming requests. // // The actual value used is the minimum of the value specified here and // the value set by the application via the gRPC client API. // If either one is not set, then the other will be used. // If neither is set, then the built-in default is used. // // If a server attempts to send an object larger than this value, it // will not be sent, and the client will see an error. // Note that 0 is a valid value, meaning that the response message must // be empty. 'maxResponseMessageBytes': number } ] } ```</p>
  92. <p>Note that new per-method parameters may be added in the future as new functionality is introduced.</p>
  93. <h1>Architecture</h1>
  94. <p>A service config is associated with a server name. The <a class="el" href="naming_8md.html">name resolver</a> plugin, when asked to resolve a particular server name, will return both the resolved addresses and the service config.</p>
  95. <p>TODO(roth): Design how the service config will be encoded in DNS.</p>
  96. <h1>APIs</h1>
  97. <p>The service config is used in the following APIs:</p>
  98. <ul>
  99. <li>In the resolver API, used by resolver plugins to return the service config to the gRPC client.</li>
  100. <li>In the gRPC client API, where users can query the channel to obtain the service config associated with the channel (for debugging purposes).</li>
  101. <li>In the gRPC client API, where users can set the service config explicitly. This is intended for use in unit tests. </li>
  102. </ul>
  103. </div></div><!-- contents -->
  104. <!-- start footer part -->
  105. <hr class="footer"/><address class="footer"><small>
  106. Generated on Wed Jun 21 2017 14:13:07 for GRPC Core by &#160;<a href="http://www.doxygen.org/index.html">
  107. <img class="footer" src="doxygen.png" alt="doxygen"/>
  108. </a> 1.8.6
  109. </small></address>
  110. </body>
  111. </html>