base.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>grpc.framework.interfaces.base.base &mdash; grpcio 1.2.0 documentation</title>
  8. <link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
  9. <link rel="index" title="Index"
  10. href="../../../../../genindex.html"/>
  11. <link rel="search" title="Search" href="../../../../../search.html"/>
  12. <link rel="top" title="grpcio 1.2.0 documentation" href="../../../../../index.html"/>
  13. <link rel="up" title="grpc" href="../../../../grpc.html"/>
  14. <script src="../../../../../_static/js/modernizr.min.js"></script>
  15. </head>
  16. <body class="wy-body-for-nav" role="document">
  17. <div class="wy-grid-for-nav">
  18. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  19. <div class="wy-side-scroll">
  20. <div class="wy-side-nav-search">
  21. <a href="../../../../../index.html" class="icon icon-home"> grpcio
  22. </a>
  23. <div class="version">
  24. 1.2.0
  25. </div>
  26. <div role="search">
  27. <form id="rtd-search-form" class="wy-form" action="../../../../../search.html" method="get">
  28. <input type="text" name="q" placeholder="Search docs" />
  29. <input type="hidden" name="check_keywords" value="yes" />
  30. <input type="hidden" name="area" value="default" />
  31. </form>
  32. </div>
  33. </div>
  34. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  35. <p class="caption"><span class="caption-text">Contents:</span></p>
  36. <ul>
  37. <li class="toctree-l1"><a class="reference internal" href="../../../../../grpc.html">grpc package</a></li>
  38. <li class="toctree-l1"><a class="reference internal" href="../../../../../grpc.html#glossary">Glossary</a></li>
  39. </ul>
  40. </div>
  41. </div>
  42. </nav>
  43. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  44. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  45. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  46. <a href="../../../../../index.html">grpcio</a>
  47. </nav>
  48. <div class="wy-nav-content">
  49. <div class="rst-content">
  50. <div role="navigation" aria-label="breadcrumbs navigation">
  51. <ul class="wy-breadcrumbs">
  52. <li><a href="../../../../../index.html">Docs</a> &raquo;</li>
  53. <li><a href="../../../../index.html">Module code</a> &raquo;</li>
  54. <li><a href="../../../../grpc.html">grpc</a> &raquo;</li>
  55. <li>grpc.framework.interfaces.base.base</li>
  56. <li class="wy-breadcrumbs-aside">
  57. </li>
  58. </ul>
  59. <hr/>
  60. </div>
  61. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  62. <div itemprop="articleBody">
  63. <h1>Source code for grpc.framework.interfaces.base.base</h1><div class="highlight"><pre>
  64. <span></span><span class="c1"># Copyright 2015, Google Inc.</span>
  65. <span class="c1"># All rights reserved.</span>
  66. <span class="c1">#</span>
  67. <span class="c1"># Redistribution and use in source and binary forms, with or without</span>
  68. <span class="c1"># modification, are permitted provided that the following conditions are</span>
  69. <span class="c1"># met:</span>
  70. <span class="c1">#</span>
  71. <span class="c1"># * Redistributions of source code must retain the above copyright</span>
  72. <span class="c1"># notice, this list of conditions and the following disclaimer.</span>
  73. <span class="c1"># * Redistributions in binary form must reproduce the above</span>
  74. <span class="c1"># copyright notice, this list of conditions and the following disclaimer</span>
  75. <span class="c1"># in the documentation and/or other materials provided with the</span>
  76. <span class="c1"># distribution.</span>
  77. <span class="c1"># * Neither the name of Google Inc. nor the names of its</span>
  78. <span class="c1"># contributors may be used to endorse or promote products derived from</span>
  79. <span class="c1"># this software without specific prior written permission.</span>
  80. <span class="c1">#</span>
  81. <span class="c1"># THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
  82. <span class="c1"># &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
  83. <span class="c1"># LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
  84. <span class="c1"># A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
  85. <span class="c1"># OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
  86. <span class="c1"># SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
  87. <span class="c1"># LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
  88. <span class="c1"># DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
  89. <span class="c1"># THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
  90. <span class="c1"># (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
  91. <span class="c1"># OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
  92. <span class="sd">&quot;&quot;&quot;The base interface of RPC Framework.</span>
  93. <span class="sd">Implementations of this interface support the conduct of &quot;operations&quot;:</span>
  94. <span class="sd">exchanges between two distinct ends of an arbitrary number of data payloads</span>
  95. <span class="sd">and metadata such as a name for the operation, initial and terminal metadata</span>
  96. <span class="sd">in each direction, and flow control. These operations may be used for transfers</span>
  97. <span class="sd">of data, remote procedure calls, status indication, or anything else</span>
  98. <span class="sd">applications choose.</span>
  99. <span class="sd">&quot;&quot;&quot;</span>
  100. <span class="c1"># threading is referenced from specification in this module.</span>
  101. <span class="kn">import</span> <span class="nn">abc</span>
  102. <span class="kn">import</span> <span class="nn">enum</span>
  103. <span class="kn">import</span> <span class="nn">threading</span> <span class="c1"># pylint: disable=unused-import</span>
  104. <span class="kn">import</span> <span class="nn">six</span>
  105. <span class="c1"># abandonment is referenced from specification in this module.</span>
  106. <span class="kn">from</span> <span class="nn">grpc.framework.foundation</span> <span class="k">import</span> <span class="n">abandonment</span> <span class="c1"># pylint: disable=unused-import</span>
  107. <span class="c1"># pylint: disable=too-many-arguments</span>
  108. <div class="viewcode-block" id="NoSuchMethodError"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.NoSuchMethodError">[docs]</a><span class="k">class</span> <span class="nc">NoSuchMethodError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
  109. <span class="sd">&quot;&quot;&quot;Indicates that an unrecognized operation has been called.</span>
  110. <span class="sd"> Attributes:</span>
  111. <span class="sd"> code: A code value to communicate to the other side of the operation</span>
  112. <span class="sd"> along with indication of operation termination. May be None.</span>
  113. <span class="sd"> details: A details value to communicate to the other side of the</span>
  114. <span class="sd"> operation along with indication of operation termination. May be None.</span>
  115. <span class="sd"> &quot;&quot;&quot;</span>
  116. <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">code</span><span class="p">,</span> <span class="n">details</span><span class="p">):</span>
  117. <span class="sd">&quot;&quot;&quot;Constructor.</span>
  118. <span class="sd"> Args:</span>
  119. <span class="sd"> code: A code value to communicate to the other side of the operation</span>
  120. <span class="sd"> along with indication of operation termination. May be None.</span>
  121. <span class="sd"> details: A details value to communicate to the other side of the</span>
  122. <span class="sd"> operation along with indication of operation termination. May be None.</span>
  123. <span class="sd"> &quot;&quot;&quot;</span>
  124. <span class="nb">super</span><span class="p">(</span><span class="n">NoSuchMethodError</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
  125. <span class="bp">self</span><span class="o">.</span><span class="n">code</span> <span class="o">=</span> <span class="n">code</span>
  126. <span class="bp">self</span><span class="o">.</span><span class="n">details</span> <span class="o">=</span> <span class="n">details</span></div>
  127. <div class="viewcode-block" id="Outcome"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Outcome">[docs]</a><span class="k">class</span> <span class="nc">Outcome</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  128. <span class="sd">&quot;&quot;&quot;The outcome of an operation.</span>
  129. <span class="sd"> Attributes:</span>
  130. <span class="sd"> kind: A Kind value coarsely identifying how the operation terminated.</span>
  131. <span class="sd"> code: An application-specific code value or None if no such value was</span>
  132. <span class="sd"> provided.</span>
  133. <span class="sd"> details: An application-specific details value or None if no such value was</span>
  134. <span class="sd"> provided.</span>
  135. <span class="sd"> &quot;&quot;&quot;</span>
  136. <span class="nd">@enum</span><span class="o">.</span><span class="n">unique</span>
  137. <div class="viewcode-block" id="Outcome.Kind"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Outcome.Kind">[docs]</a> <span class="k">class</span> <span class="nc">Kind</span><span class="p">(</span><span class="n">enum</span><span class="o">.</span><span class="n">Enum</span><span class="p">):</span>
  138. <span class="sd">&quot;&quot;&quot;Ways in which an operation can terminate.&quot;&quot;&quot;</span>
  139. <span class="n">COMPLETED</span> <span class="o">=</span> <span class="s1">&#39;completed&#39;</span>
  140. <span class="n">CANCELLED</span> <span class="o">=</span> <span class="s1">&#39;cancelled&#39;</span>
  141. <span class="n">EXPIRED</span> <span class="o">=</span> <span class="s1">&#39;expired&#39;</span>
  142. <span class="n">LOCAL_SHUTDOWN</span> <span class="o">=</span> <span class="s1">&#39;local shutdown&#39;</span>
  143. <span class="n">REMOTE_SHUTDOWN</span> <span class="o">=</span> <span class="s1">&#39;remote shutdown&#39;</span>
  144. <span class="n">RECEPTION_FAILURE</span> <span class="o">=</span> <span class="s1">&#39;reception failure&#39;</span>
  145. <span class="n">TRANSMISSION_FAILURE</span> <span class="o">=</span> <span class="s1">&#39;transmission failure&#39;</span>
  146. <span class="n">LOCAL_FAILURE</span> <span class="o">=</span> <span class="s1">&#39;local failure&#39;</span>
  147. <span class="n">REMOTE_FAILURE</span> <span class="o">=</span> <span class="s1">&#39;remote failure&#39;</span></div></div>
  148. <div class="viewcode-block" id="Completion"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Completion">[docs]</a><span class="k">class</span> <span class="nc">Completion</span><span class="p">(</span><span class="n">six</span><span class="o">.</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">)):</span>
  149. <span class="sd">&quot;&quot;&quot;An aggregate of the values exchanged upon operation completion.</span>
  150. <span class="sd"> Attributes:</span>
  151. <span class="sd"> terminal_metadata: A terminal metadata value for the operaton.</span>
  152. <span class="sd"> code: A code value for the operation.</span>
  153. <span class="sd"> message: A message value for the operation.</span>
  154. <span class="sd"> &quot;&quot;&quot;</span></div>
  155. <div class="viewcode-block" id="OperationContext"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.OperationContext">[docs]</a><span class="k">class</span> <span class="nc">OperationContext</span><span class="p">(</span><span class="n">six</span><span class="o">.</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">)):</span>
  156. <span class="sd">&quot;&quot;&quot;Provides operation-related information and action.&quot;&quot;&quot;</span>
  157. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  158. <div class="viewcode-block" id="OperationContext.outcome"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.OperationContext.outcome">[docs]</a> <span class="k">def</span> <span class="nf">outcome</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  159. <span class="sd">&quot;&quot;&quot;Indicates the operation&#39;s outcome (or that the operation is ongoing).</span>
  160. <span class="sd"> Returns:</span>
  161. <span class="sd"> None if the operation is still active or the Outcome value for the</span>
  162. <span class="sd"> operation if it has terminated.</span>
  163. <span class="sd"> &quot;&quot;&quot;</span>
  164. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div>
  165. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  166. <div class="viewcode-block" id="OperationContext.add_termination_callback"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.OperationContext.add_termination_callback">[docs]</a> <span class="k">def</span> <span class="nf">add_termination_callback</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">callback</span><span class="p">):</span>
  167. <span class="sd">&quot;&quot;&quot;Adds a function to be called upon operation termination.</span>
  168. <span class="sd"> Args:</span>
  169. <span class="sd"> callback: A callable to be passed an Outcome value on operation</span>
  170. <span class="sd"> termination.</span>
  171. <span class="sd"> Returns:</span>
  172. <span class="sd"> None if the operation has not yet terminated and the passed callback will</span>
  173. <span class="sd"> later be called when it does terminate, or if the operation has already</span>
  174. <span class="sd"> terminated an Outcome value describing the operation termination and the</span>
  175. <span class="sd"> passed callback will not be called as a result of this method call.</span>
  176. <span class="sd"> &quot;&quot;&quot;</span>
  177. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div>
  178. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  179. <div class="viewcode-block" id="OperationContext.time_remaining"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.OperationContext.time_remaining">[docs]</a> <span class="k">def</span> <span class="nf">time_remaining</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  180. <span class="sd">&quot;&quot;&quot;Describes the length of allowed time remaining for the operation.</span>
  181. <span class="sd"> Returns:</span>
  182. <span class="sd"> A nonnegative float indicating the length of allowed time in seconds</span>
  183. <span class="sd"> remaining for the operation to complete before it is considered to have</span>
  184. <span class="sd"> timed out. Zero is returned if the operation has terminated.</span>
  185. <span class="sd"> &quot;&quot;&quot;</span>
  186. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div>
  187. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  188. <div class="viewcode-block" id="OperationContext.cancel"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.OperationContext.cancel">[docs]</a> <span class="k">def</span> <span class="nf">cancel</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  189. <span class="sd">&quot;&quot;&quot;Cancels the operation if the operation has not yet terminated.&quot;&quot;&quot;</span>
  190. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div>
  191. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  192. <div class="viewcode-block" id="OperationContext.fail"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.OperationContext.fail">[docs]</a> <span class="k">def</span> <span class="nf">fail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exception</span><span class="p">):</span>
  193. <span class="sd">&quot;&quot;&quot;Indicates that the operation has failed.</span>
  194. <span class="sd"> Args:</span>
  195. <span class="sd"> exception: An exception germane to the operation failure. May be None.</span>
  196. <span class="sd"> &quot;&quot;&quot;</span>
  197. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div></div>
  198. <div class="viewcode-block" id="Operator"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Operator">[docs]</a><span class="k">class</span> <span class="nc">Operator</span><span class="p">(</span><span class="n">six</span><span class="o">.</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">)):</span>
  199. <span class="sd">&quot;&quot;&quot;An interface through which to participate in an operation.&quot;&quot;&quot;</span>
  200. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  201. <div class="viewcode-block" id="Operator.advance"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Operator.advance">[docs]</a> <span class="k">def</span> <span class="nf">advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
  202. <span class="n">initial_metadata</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
  203. <span class="n">payload</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
  204. <span class="n">completion</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
  205. <span class="n">allowance</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
  206. <span class="sd">&quot;&quot;&quot;Progresses the operation.</span>
  207. <span class="sd"> Args:</span>
  208. <span class="sd"> initial_metadata: An initial metadata value. Only one may ever be</span>
  209. <span class="sd"> communicated in each direction for an operation, and they must be</span>
  210. <span class="sd"> communicated no later than either the first payload or the completion.</span>
  211. <span class="sd"> payload: A payload value.</span>
  212. <span class="sd"> completion: A Completion value. May only ever be non-None once in either</span>
  213. <span class="sd"> direction, and no payloads may be passed after it has been communicated.</span>
  214. <span class="sd"> allowance: A positive integer communicating the number of additional</span>
  215. <span class="sd"> payloads allowed to be passed by the remote side of the operation.</span>
  216. <span class="sd"> &quot;&quot;&quot;</span>
  217. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div></div>
  218. <div class="viewcode-block" id="ProtocolReceiver"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.ProtocolReceiver">[docs]</a><span class="k">class</span> <span class="nc">ProtocolReceiver</span><span class="p">(</span><span class="n">six</span><span class="o">.</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">)):</span>
  219. <span class="sd">&quot;&quot;&quot;A means of receiving protocol values during an operation.&quot;&quot;&quot;</span>
  220. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  221. <div class="viewcode-block" id="ProtocolReceiver.context"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.ProtocolReceiver.context">[docs]</a> <span class="k">def</span> <span class="nf">context</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">protocol_context</span><span class="p">):</span>
  222. <span class="sd">&quot;&quot;&quot;Accepts the protocol context object for the operation.</span>
  223. <span class="sd"> Args:</span>
  224. <span class="sd"> protocol_context: The protocol context object for the operation.</span>
  225. <span class="sd"> &quot;&quot;&quot;</span>
  226. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div></div>
  227. <div class="viewcode-block" id="Subscription"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Subscription">[docs]</a><span class="k">class</span> <span class="nc">Subscription</span><span class="p">(</span><span class="n">six</span><span class="o">.</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">)):</span>
  228. <span class="sd">&quot;&quot;&quot;Describes customer code&#39;s interest in values from the other side.</span>
  229. <span class="sd"> Attributes:</span>
  230. <span class="sd"> kind: A Kind value describing the overall kind of this value.</span>
  231. <span class="sd"> termination_callback: A callable to be passed the Outcome associated with</span>
  232. <span class="sd"> the operation after it has terminated. Must be non-None if kind is</span>
  233. <span class="sd"> Kind.TERMINATION_ONLY. Must be None otherwise.</span>
  234. <span class="sd"> allowance: A callable behavior that accepts positive integers representing</span>
  235. <span class="sd"> the number of additional payloads allowed to be passed to the other side</span>
  236. <span class="sd"> of the operation. Must be None if kind is Kind.FULL. Must not be None</span>
  237. <span class="sd"> otherwise.</span>
  238. <span class="sd"> operator: An Operator to be passed values from the other side of the</span>
  239. <span class="sd"> operation. Must be non-None if kind is Kind.FULL. Must be None otherwise.</span>
  240. <span class="sd"> protocol_receiver: A ProtocolReceiver to be passed protocol objects as they</span>
  241. <span class="sd"> become available during the operation. Must be non-None if kind is</span>
  242. <span class="sd"> Kind.FULL.</span>
  243. <span class="sd"> &quot;&quot;&quot;</span>
  244. <span class="nd">@enum</span><span class="o">.</span><span class="n">unique</span>
  245. <div class="viewcode-block" id="Subscription.Kind"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Subscription.Kind">[docs]</a> <span class="k">class</span> <span class="nc">Kind</span><span class="p">(</span><span class="n">enum</span><span class="o">.</span><span class="n">Enum</span><span class="p">):</span>
  246. <span class="n">NONE</span> <span class="o">=</span> <span class="s1">&#39;none&#39;</span>
  247. <span class="n">TERMINATION_ONLY</span> <span class="o">=</span> <span class="s1">&#39;termination only&#39;</span>
  248. <span class="n">FULL</span> <span class="o">=</span> <span class="s1">&#39;full&#39;</span></div></div>
  249. <div class="viewcode-block" id="Servicer"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Servicer">[docs]</a><span class="k">class</span> <span class="nc">Servicer</span><span class="p">(</span><span class="n">six</span><span class="o">.</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">)):</span>
  250. <span class="sd">&quot;&quot;&quot;Interface for service implementations.&quot;&quot;&quot;</span>
  251. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  252. <div class="viewcode-block" id="Servicer.service"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.Servicer.service">[docs]</a> <span class="k">def</span> <span class="nf">service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">group</span><span class="p">,</span> <span class="n">method</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">output_operator</span><span class="p">):</span>
  253. <span class="sd">&quot;&quot;&quot;Services an operation.</span>
  254. <span class="sd"> Args:</span>
  255. <span class="sd"> group: The group identifier of the operation to be serviced.</span>
  256. <span class="sd"> method: The method identifier of the operation to be serviced.</span>
  257. <span class="sd"> context: An OperationContext object affording contextual information and</span>
  258. <span class="sd"> actions.</span>
  259. <span class="sd"> output_operator: An Operator that will accept output values of the</span>
  260. <span class="sd"> operation.</span>
  261. <span class="sd"> Returns:</span>
  262. <span class="sd"> A Subscription via which this object may or may not accept more values of</span>
  263. <span class="sd"> the operation.</span>
  264. <span class="sd"> Raises:</span>
  265. <span class="sd"> NoSuchMethodError: If this Servicer does not handle operations with the</span>
  266. <span class="sd"> given group and method.</span>
  267. <span class="sd"> abandonment.Abandoned: If the operation has been aborted and there no</span>
  268. <span class="sd"> longer is any reason to service the operation.</span>
  269. <span class="sd"> &quot;&quot;&quot;</span>
  270. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div></div>
  271. <div class="viewcode-block" id="End"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.End">[docs]</a><span class="k">class</span> <span class="nc">End</span><span class="p">(</span><span class="n">six</span><span class="o">.</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">)):</span>
  272. <span class="sd">&quot;&quot;&quot;Common type for entry-point objects on both sides of an operation.&quot;&quot;&quot;</span>
  273. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  274. <div class="viewcode-block" id="End.start"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.End.start">[docs]</a> <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  275. <span class="sd">&quot;&quot;&quot;Starts this object&#39;s service of operations.&quot;&quot;&quot;</span>
  276. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div>
  277. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  278. <div class="viewcode-block" id="End.stop"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.End.stop">[docs]</a> <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">grace</span><span class="p">):</span>
  279. <span class="sd">&quot;&quot;&quot;Stops this object&#39;s service of operations.</span>
  280. <span class="sd"> This object will refuse service of new operations as soon as this method is</span>
  281. <span class="sd"> called but operations under way at the time of the call may be given a</span>
  282. <span class="sd"> grace period during which they are allowed to finish.</span>
  283. <span class="sd"> Args:</span>
  284. <span class="sd"> grace: A duration of time in seconds to allow ongoing operations to</span>
  285. <span class="sd"> terminate before being forcefully terminated by the stopping of this</span>
  286. <span class="sd"> End. May be zero to terminate all ongoing operations and immediately</span>
  287. <span class="sd"> stop.</span>
  288. <span class="sd"> Returns:</span>
  289. <span class="sd"> A threading.Event that will be set to indicate all operations having</span>
  290. <span class="sd"> terminated and this End having completely stopped. The returned event</span>
  291. <span class="sd"> may not be set until after the full grace period (if some ongoing</span>
  292. <span class="sd"> operation continues for the full length of the period) or it may be set</span>
  293. <span class="sd"> much sooner (if for example this End had no operations in progress at</span>
  294. <span class="sd"> the time its stop method was called).</span>
  295. <span class="sd"> &quot;&quot;&quot;</span>
  296. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div>
  297. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  298. <div class="viewcode-block" id="End.operate"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.End.operate">[docs]</a> <span class="k">def</span> <span class="nf">operate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
  299. <span class="n">group</span><span class="p">,</span>
  300. <span class="n">method</span><span class="p">,</span>
  301. <span class="n">subscription</span><span class="p">,</span>
  302. <span class="n">timeout</span><span class="p">,</span>
  303. <span class="n">initial_metadata</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
  304. <span class="n">payload</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
  305. <span class="n">completion</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
  306. <span class="n">protocol_options</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
  307. <span class="sd">&quot;&quot;&quot;Commences an operation.</span>
  308. <span class="sd"> Args:</span>
  309. <span class="sd"> group: The group identifier of the invoked operation.</span>
  310. <span class="sd"> method: The method identifier of the invoked operation.</span>
  311. <span class="sd"> subscription: A Subscription to which the results of the operation will be</span>
  312. <span class="sd"> passed.</span>
  313. <span class="sd"> timeout: A length of time in seconds to allow for the operation.</span>
  314. <span class="sd"> initial_metadata: An initial metadata value to be sent to the other side</span>
  315. <span class="sd"> of the operation. May be None if the initial metadata will be later</span>
  316. <span class="sd"> passed via the returned operator or if there will be no initial metadata</span>
  317. <span class="sd"> passed at all.</span>
  318. <span class="sd"> payload: An initial payload for the operation.</span>
  319. <span class="sd"> completion: A Completion value indicating the end of transmission to the</span>
  320. <span class="sd"> other side of the operation.</span>
  321. <span class="sd"> protocol_options: A value specified by the provider of a Base interface</span>
  322. <span class="sd"> implementation affording custom state and behavior.</span>
  323. <span class="sd"> Returns:</span>
  324. <span class="sd"> A pair of objects affording information about the operation and action</span>
  325. <span class="sd"> continuing the operation. The first element of the returned pair is an</span>
  326. <span class="sd"> OperationContext for the operation and the second element of the</span>
  327. <span class="sd"> returned pair is an Operator to which operation values not passed in</span>
  328. <span class="sd"> this call should later be passed.</span>
  329. <span class="sd"> &quot;&quot;&quot;</span>
  330. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div>
  331. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  332. <div class="viewcode-block" id="End.operation_stats"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.End.operation_stats">[docs]</a> <span class="k">def</span> <span class="nf">operation_stats</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  333. <span class="sd">&quot;&quot;&quot;Reports the number of terminated operations broken down by outcome.</span>
  334. <span class="sd"> Returns:</span>
  335. <span class="sd"> A dictionary from Outcome.Kind value to an integer identifying the number</span>
  336. <span class="sd"> of operations that terminated with that outcome kind.</span>
  337. <span class="sd"> &quot;&quot;&quot;</span>
  338. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div>
  339. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  340. <div class="viewcode-block" id="End.add_idle_action"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.base.html#grpc.framework.interfaces.base.base.End.add_idle_action">[docs]</a> <span class="k">def</span> <span class="nf">add_idle_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">action</span><span class="p">):</span>
  341. <span class="sd">&quot;&quot;&quot;Adds an action to be called when this End has no ongoing operations.</span>
  342. <span class="sd"> Args:</span>
  343. <span class="sd"> action: A callable that accepts no arguments.</span>
  344. <span class="sd"> &quot;&quot;&quot;</span>
  345. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div></div>
  346. </pre></div>
  347. </div>
  348. <div class="articleComments">
  349. </div>
  350. </div>
  351. <footer>
  352. <hr/>
  353. <div role="contentinfo">
  354. <p>
  355. &copy; Copyright 2016, The gRPC Authors.
  356. </p>
  357. </div>
  358. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  359. </footer>
  360. </div>
  361. </div>
  362. </section>
  363. </div>
  364. <script type="text/javascript">
  365. var DOCUMENTATION_OPTIONS = {
  366. URL_ROOT:'../../../../../',
  367. VERSION:'1.2.0',
  368. COLLAPSE_INDEX:false,
  369. FILE_SUFFIX:'.html',
  370. HAS_SOURCE: true,
  371. SOURCELINK_SUFFIX: '.txt'
  372. };
  373. </script>
  374. <script type="text/javascript" src="../../../../../_static/jquery.js"></script>
  375. <script type="text/javascript" src="../../../../../_static/underscore.js"></script>
  376. <script type="text/javascript" src="../../../../../_static/doctools.js"></script>
  377. <script type="text/javascript" src="../../../../../_static/js/theme.js"></script>
  378. <script type="text/javascript">
  379. jQuery(function () {
  380. SphinxRtdTheme.StickyNav.enable();
  381. });
  382. </script>
  383. </body>
  384. </html>