123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.17"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <title>GRPC C++: Service Config in gRPC</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <link href="search/search.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="search/searchdata.js"></script>
- <script type="text/javascript" src="search/search.js"></script>
- <link href="doxygen.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
- <td id="projectalign" style="padding-left: 0.5em;">
- <div id="projectname">GRPC C++
-  <span id="projectnumber">1.36.1</span>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.17 -->
- <script type="text/javascript">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- /* @license-end */
- </script>
- <script type="text/javascript" src="menudata.js"></script>
- <script type="text/javascript" src="menu.js"></script>
- <script type="text/javascript">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- $(function() {
- initMenu('',true,false,'search.php','Search');
- $(document).ready(function() { init_search(); });
- });
- /* @license-end */</script>
- <div id="main-nav"></div>
- <!-- window showing the filter options -->
- <div id="MSearchSelectWindow"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- onkeydown="return searchBox.OnSearchSelectKey(event)">
- </div>
- <!-- iframe showing the search results (closed by default) -->
- <div id="MSearchResultsWindow">
- <iframe src="javascript:void(0)" frameborder="0"
- name="MSearchResults" id="MSearchResults">
- </iframe>
- </div>
- </div><!-- top -->
- <div class="PageDoc"><div class="header">
- <div class="headertitle">
- <div class="title">Service Config in gRPC </div> </div>
- </div><!--header-->
- <div class="contents">
- <div class="textblock"><h1><a class="anchor" id="autotoc_md220"></a>
- Objective</h1>
- <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>
- <h1><a class="anchor" id="autotoc_md221"></a>
- Format</h1>
- <p>The format of the service config is defined by the <a href="https://github.com/grpc/grpc-proto/blob/master/grpc/service_config/service_config.proto"><code>grpc.service_config.ServiceConfig</code> protocol buffer message</a>. Note that new fields may be added in the future as new functionality is introduced.</p>
- <h1><a class="anchor" id="autotoc_md222"></a>
- Architecture</h1>
- <p>A service config is associated with a server name. The <a class="el" href="naming_8md.html">name</a>resolver" plugin, when asked to resolve a particular server name, will return both the resolved addresses and the service config.</p>
- <p>The name resolver returns the service config to the gRPC client in JSON form. Individual resolver implementations determine where and in what format the service config is stored. If the resolver implemention obtains the service config in protobuf form, it must convert it to JSON using the normal <a href="https://developers.google.com/protocol-buffers/docs/proto3#json">protobuf to JSON translation rules</a>. Alternatively, a resolver implementation may obtain the service config already in JSON form, in which case it may return it directly.</p>
- <p>For details of how the DNS resolver plugin supports service configs, see <a href="https://github.com/grpc/proposal/blob/master/A2-service-configs-in-dns.md">gRFC A2: Service Config via DNS</a>.</p>
- <h1><a class="anchor" id="autotoc_md223"></a>
- Example</h1>
- <p>Here is an example service config in protobuf form:</p>
- <div class="fragment"><div class="line">{</div>
- <div class="line"> // Use round_robin LB policy.</div>
- <div class="line"> load_balancing_config: { round_robin: {} }</div>
- <div class="line"> // This method config applies to method "foo/bar" and to all methods</div>
- <div class="line"> // of service "baz".</div>
- <div class="line"> method_config: {</div>
- <div class="line"> name: {</div>
- <div class="line"> service: "foo"</div>
- <div class="line"> method: "bar"</div>
- <div class="line"> }</div>
- <div class="line"> name: {</div>
- <div class="line"> service: "baz"</div>
- <div class="line"> }</div>
- <div class="line"> // Default timeout for matching methods.</div>
- <div class="line"> timeout: {</div>
- <div class="line"> seconds: 1</div>
- <div class="line"> nanos: 1</div>
- <div class="line"> }</div>
- <div class="line"> }</div>
- <div class="line">}</div>
- </div><!-- fragment --><p>Here is the same example service config in JSON form:</p>
- <div class="fragment"><div class="line">{</div>
- <div class="line"> "loadBalancingConfig": [ { "round_robin": {} } ],</div>
- <div class="line"> "methodConfig": [</div>
- <div class="line"> {</div>
- <div class="line"> "name": [</div>
- <div class="line"> { "service": "foo", "method": "bar" },</div>
- <div class="line"> { "service": "baz" }</div>
- <div class="line"> ],</div>
- <div class="line"> "timeout": "1.0000000001s"</div>
- <div class="line"> }</div>
- <div class="line"> ]</div>
- <div class="line">}</div>
- </div><!-- fragment --><h1><a class="anchor" id="autotoc_md224"></a>
- APIs</h1>
- <p>The service config is used in the following APIs:</p>
- <ul>
- <li>In the resolver API, used by resolver plugins to return the service config to the gRPC client.</li>
- <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>
- <li>In the gRPC client API, where users can set the service config explicitly. This can be used to set the config in unit tests. It can also be used to set the default config that will be used if the resolver plugin does not return a service config. </li>
- </ul>
- </div></div><!-- contents -->
- </div><!-- PageDoc -->
- <!-- start footer part -->
- <hr class="footer"/><address class="footer"><small>
- Generated on Wed Mar 3 2021 19:17:23 for GRPC C++ by  <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/>
- </a> 1.8.17
- </small></address>
- </body>
- </html>
|