md_doc_service_config.html 12 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.13"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>GRPC Core: Service Config in gRPC</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="search/searchdata.js"></script>
  14. <script type="text/javascript" src="search/search.js"></script>
  15. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  19. <div id="titlearea">
  20. <table cellspacing="0" cellpadding="0">
  21. <tbody>
  22. <tr style="height: 56px;">
  23. <td id="projectalign" style="padding-left: 0.5em;">
  24. <div id="projectname">GRPC Core
  25. &#160;<span id="projectnumber">6.0.0</span>
  26. </div>
  27. </td>
  28. </tr>
  29. </tbody>
  30. </table>
  31. </div>
  32. <!-- end header part -->
  33. <!-- Generated by Doxygen 1.8.13 -->
  34. <script type="text/javascript">
  35. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  36. </script>
  37. <script type="text/javascript" src="menudata.js"></script>
  38. <script type="text/javascript" src="menu.js"></script>
  39. <script type="text/javascript">
  40. $(function() {
  41. initMenu('',true,false,'search.php','Search');
  42. $(document).ready(function() { init_search(); });
  43. });
  44. </script>
  45. <div id="main-nav"></div>
  46. <!-- window showing the filter options -->
  47. <div id="MSearchSelectWindow"
  48. onmouseover="return searchBox.OnSearchSelectShow()"
  49. onmouseout="return searchBox.OnSearchSelectHide()"
  50. onkeydown="return searchBox.OnSearchSelectKey(event)">
  51. </div>
  52. <!-- iframe showing the search results (closed by default) -->
  53. <div id="MSearchResultsWindow">
  54. <iframe src="javascript:void(0)" frameborder="0"
  55. name="MSearchResults" id="MSearchResults">
  56. </iframe>
  57. </div>
  58. </div><!-- top -->
  59. <div class="header">
  60. <div class="headertitle">
  61. <div class="title">Service Config in gRPC </div> </div>
  62. </div><!--header-->
  63. <div class="contents">
  64. <div class="textblock"><h1>Objective</h1>
  65. <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>
  66. <h1>Format</h1>
  67. <p>The service config is a JSON string of the following form:</p>
  68. <div class="fragment"><div class="line">{</div><div class="line"> // Load balancing policy name (case insensitive).</div><div class="line"> // Currently, the only selectable client-side policy provided with gRPC</div><div class="line"> // is &#39;round_robin&#39;, but third parties may add their own policies.</div><div class="line"> // This field is optional; if unset, the default behavior is to pick</div><div class="line"> // the first available backend.</div><div class="line"> // If the policy name is set via the client API, that value overrides</div><div class="line"> // the value specified here.</div><div class="line"> //</div><div class="line"> // Note that if the resolver returns at least one balancer address (as</div><div class="line"> // opposed to backend addresses), gRPC will use grpclb (see</div><div class="line"> // https://github.com/grpc/grpc/blob/master/doc/load-balancing.md),</div><div class="line"> // regardless of what LB policy is requested either here or via the</div><div class="line"> // client API.</div><div class="line"> &#39;loadBalancingPolicy&#39;: string,</div><div class="line"></div><div class="line"> // Per-method configuration. Optional.</div><div class="line"> &#39;methodConfig&#39;: [</div><div class="line"> {</div><div class="line"> // The names of the methods to which this method config applies. There</div><div class="line"> // must be at least one name. Each name entry must be unique across the</div><div class="line"> // entire service config. If the &#39;method&#39; field is empty, then this</div><div class="line"> // method config specifies the defaults for all methods for the specified</div><div class="line"> // service.</div><div class="line"> //</div><div class="line"> // For example, let&#39;s say that the service config contains the following</div><div class="line"> // method config entries:</div><div class="line"> //</div><div class="line"> // &#39;methodConfig&#39;: [</div><div class="line"> // { &#39;name&#39;: [ { &#39;service&#39;: &#39;MyService&#39; } ] ... },</div><div class="line"> // { &#39;name&#39;: [ { &#39;service&#39;: &#39;MyService&#39;, &#39;method&#39;: &#39;Foo&#39; } ] ... }</div><div class="line"> // ]</div><div class="line"> //</div><div class="line"> // For a request for MyService/Foo, we will use the second entry, because</div><div class="line"> // it exactly matches the service and method name.</div><div class="line"> // For a request for MyService/Bar, we will use the first entry, because</div><div class="line"> // it provides the default for all methods of MyService.</div><div class="line"> &#39;name&#39;: [</div><div class="line"> {</div><div class="line"> // RPC service name. Required.</div><div class="line"> // If using gRPC with protobuf as the IDL, then this will be of</div><div class="line"> // the form &quot;pkg.service_name&quot;, where &quot;pkg&quot; is the package name</div><div class="line"> // defined in the proto file.</div><div class="line"> &#39;service&#39;: string,</div><div class="line"></div><div class="line"> // RPC method name. Optional (see above).</div><div class="line"> &#39;method&#39;: string,</div><div class="line"> }</div><div class="line"> ],</div><div class="line"></div><div class="line"> // Whether RPCs sent to this method should wait until the connection is</div><div class="line"> // ready by default. If false, the RPC will abort immediately if there</div><div class="line"> // is a transient failure connecting to the server. Otherwise, gRPC will</div><div class="line"> // attempt to connect until the deadline is exceeded.</div><div class="line"> //</div><div class="line"> // The value specified via the gRPC client API will override the value</div><div class="line"> // set here. However, note that setting the value in the client API will</div><div class="line"> // also affect transient errors encountered during name resolution,</div><div class="line"> // which cannot be caught by the value here, since the service config</div><div class="line"> // is obtained by the gRPC client via name resolution.</div><div class="line"> &#39;waitForReady&#39;: bool,</div><div class="line"></div><div class="line"> // The default timeout in seconds for RPCs sent to this method. This can</div><div class="line"> // be overridden in code. If no reply is received in the specified amount</div><div class="line"> // of time, the request is aborted and a deadline-exceeded error status</div><div class="line"> // is returned to the caller.</div><div class="line"> //</div><div class="line"> // The actual deadline used will be the minimum of the value specified</div><div class="line"> // here and the value set by the application via the gRPC client API.</div><div class="line"> // If either one is not set, then the other will be used.</div><div class="line"> // If neither is set, then the request has no deadline.</div><div class="line"> //</div><div class="line"> // The format of the value is that of the &#39;Duration&#39; type defined here:</div><div class="line"> // https://developers.google.com/protocol-buffers/docs/proto3#json</div><div class="line"> &#39;timeout&#39;: string,</div><div class="line"></div><div class="line"> // The maximum allowed payload size for an individual request or object</div><div class="line"> // in a stream (client-&gt;server) in bytes. The size which is measured is</div><div class="line"> // the serialized, uncompressed payload in bytes. This applies both</div><div class="line"> // to streaming and non-streaming requests.</div><div class="line"> //</div><div class="line"> // The actual value used is the minimum of the value specified here and</div><div class="line"> // the value set by the application via the gRPC client API.</div><div class="line"> // If either one is not set, then the other will be used.</div><div class="line"> // If neither is set, then the built-in default is used.</div><div class="line"> //</div><div class="line"> // If a client attempts to send an object larger than this value, it</div><div class="line"> // will not be sent and the client will see an error.</div><div class="line"> // Note that 0 is a valid value, meaning that the request message must</div><div class="line"> // be empty.</div><div class="line"> &#39;maxRequestMessageBytes&#39;: number,</div><div class="line"></div><div class="line"> // The maximum allowed payload size for an individual response or object</div><div class="line"> // in a stream (server-&gt;client) in bytes. The size which is measured is</div><div class="line"> // the serialized, uncompressed payload in bytes. This applies both</div><div class="line"> // to streaming and non-streaming requests.</div><div class="line"> //</div><div class="line"> // The actual value used is the minimum of the value specified here and</div><div class="line"> // the value set by the application via the gRPC client API.</div><div class="line"> // If either one is not set, then the other will be used.</div><div class="line"> // If neither is set, then the built-in default is used.</div><div class="line"> //</div><div class="line"> // If a server attempts to send an object larger than this value, it</div><div class="line"> // will not be sent, and the client will see an error.</div><div class="line"> // Note that 0 is a valid value, meaning that the response message must</div><div class="line"> // be empty.</div><div class="line"> &#39;maxResponseMessageBytes&#39;: number</div><div class="line"> }</div><div class="line"> ]</div><div class="line">}</div></div><!-- fragment --><p>Note that new per-method parameters may be added in the future as new functionality is introduced.</p>
  69. <h1>Architecture</h1>
  70. <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>
  71. <p>TODO(roth): Design how the service config will be encoded in DNS.</p>
  72. <h1>APIs</h1>
  73. <p>The service config is used in the following APIs:</p>
  74. <ul>
  75. <li>In the resolver API, used by resolver plugins to return the service config to the gRPC client.</li>
  76. <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>
  77. <li>In the gRPC client API, where users can set the service config explicitly. This is intended for use in unit tests. </li>
  78. </ul>
  79. </div></div><!-- contents -->
  80. <!-- start footer part -->
  81. <hr class="footer"/><address class="footer"><small>
  82. Generated on Fri Apr 13 2018 15:03:52 for GRPC Core by &#160;<a href="http://www.doxygen.org/index.html">
  83. <img class="footer" src="doxygen.png" alt="doxygen"/>
  84. </a> 1.8.13
  85. </small></address>
  86. </body>
  87. </html>