links.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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.links.links &mdash; grpcio 0.13.1rc1 documentation</title>
  8. <link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
  9. <link rel="top" title="grpcio 0.13.1rc1 documentation" href="../../../../../index.html"/>
  10. <link rel="up" title="Module code" href="../../../../index.html"/>
  11. <script src="../../../../../_static/js/modernizr.min.js"></script>
  12. </head>
  13. <body class="wy-body-for-nav" role="document">
  14. <div class="wy-grid-for-nav">
  15. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  16. <div class="wy-side-scroll">
  17. <div class="wy-side-nav-search">
  18. <a href="../../../../../index.html" class="icon icon-home"> grpcio
  19. </a>
  20. <div class="version">
  21. 0.13.1rc1
  22. </div>
  23. <div role="search">
  24. <form id="rtd-search-form" class="wy-form" action="../../../../../search.html" method="get">
  25. <input type="text" name="q" placeholder="Search docs" />
  26. <input type="hidden" name="check_keywords" value="yes" />
  27. <input type="hidden" name="area" value="default" />
  28. </form>
  29. </div>
  30. </div>
  31. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  32. <ul>
  33. <li class="toctree-l1"><a class="reference internal" href="../../../../../grpc.html">grpc package</a></li>
  34. </ul>
  35. </div>
  36. </div>
  37. </nav>
  38. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  39. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  40. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  41. <a href="../../../../../index.html">grpcio</a>
  42. </nav>
  43. <div class="wy-nav-content">
  44. <div class="rst-content">
  45. <div role="navigation" aria-label="breadcrumbs navigation">
  46. <ul class="wy-breadcrumbs">
  47. <li><a href="../../../../../index.html">Docs</a> &raquo;</li>
  48. <li><a href="../../../../index.html">Module code</a> &raquo;</li>
  49. <li>grpc.framework.interfaces.links.links</li>
  50. <li class="wy-breadcrumbs-aside">
  51. </li>
  52. </ul>
  53. <hr/>
  54. </div>
  55. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  56. <div itemprop="articleBody">
  57. <h1>Source code for grpc.framework.interfaces.links.links</h1><div class="highlight"><pre>
  58. <span></span><span class="c1"># Copyright 2015, Google Inc.</span>
  59. <span class="c1"># All rights reserved.</span>
  60. <span class="c1">#</span>
  61. <span class="c1"># Redistribution and use in source and binary forms, with or without</span>
  62. <span class="c1"># modification, are permitted provided that the following conditions are</span>
  63. <span class="c1"># met:</span>
  64. <span class="c1">#</span>
  65. <span class="c1"># * Redistributions of source code must retain the above copyright</span>
  66. <span class="c1"># notice, this list of conditions and the following disclaimer.</span>
  67. <span class="c1"># * Redistributions in binary form must reproduce the above</span>
  68. <span class="c1"># copyright notice, this list of conditions and the following disclaimer</span>
  69. <span class="c1"># in the documentation and/or other materials provided with the</span>
  70. <span class="c1"># distribution.</span>
  71. <span class="c1"># * Neither the name of Google Inc. nor the names of its</span>
  72. <span class="c1"># contributors may be used to endorse or promote products derived from</span>
  73. <span class="c1"># this software without specific prior written permission.</span>
  74. <span class="c1">#</span>
  75. <span class="c1"># THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
  76. <span class="c1"># &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
  77. <span class="c1"># LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
  78. <span class="c1"># A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
  79. <span class="c1"># OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
  80. <span class="c1"># SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
  81. <span class="c1"># LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
  82. <span class="c1"># DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
  83. <span class="c1"># THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
  84. <span class="c1"># (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
  85. <span class="c1"># OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
  86. <span class="sd">&quot;&quot;&quot;The low-level ticket-exchanging-links interface of RPC Framework.&quot;&quot;&quot;</span>
  87. <span class="kn">import</span> <span class="nn">abc</span>
  88. <span class="kn">import</span> <span class="nn">collections</span>
  89. <span class="kn">import</span> <span class="nn">enum</span>
  90. <div class="viewcode-block" id="Protocol"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.links.html#grpc.framework.interfaces.links.links.Protocol">[docs]</a><span class="k">class</span> <span class="nc">Protocol</span><span class="p">(</span><span class="n">collections</span><span class="o">.</span><span class="n">namedtuple</span><span class="p">(</span><span class="s1">&#39;Protocol&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;kind&#39;</span><span class="p">,</span> <span class="s1">&#39;value&#39;</span><span class="p">,))):</span>
  91. <span class="sd">&quot;&quot;&quot;A sum type for handles to a system that transmits tickets.</span>
  92. <span class="sd"> Attributes:</span>
  93. <span class="sd"> kind: A Kind value identifying the kind of value being passed.</span>
  94. <span class="sd"> value: The value being passed between the high-level application and the</span>
  95. <span class="sd"> system affording ticket transport.</span>
  96. <span class="sd"> &quot;&quot;&quot;</span>
  97. <span class="nd">@enum</span><span class="o">.</span><span class="n">unique</span>
  98. <div class="viewcode-block" id="Protocol.Kind"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.links.html#grpc.framework.interfaces.links.links.Protocol.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>
  99. <span class="n">CALL_OPTION</span> <span class="o">=</span> <span class="s1">&#39;call option&#39;</span>
  100. <span class="n">SERVICER_CONTEXT</span> <span class="o">=</span> <span class="s1">&#39;servicer context&#39;</span>
  101. <span class="n">INVOCATION_CONTEXT</span> <span class="o">=</span> <span class="s1">&#39;invocation context&#39;</span></div></div>
  102. <div class="viewcode-block" id="Ticket"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.links.html#grpc.framework.interfaces.links.links.Ticket">[docs]</a><span class="k">class</span> <span class="nc">Ticket</span><span class="p">(</span>
  103. <span class="n">collections</span><span class="o">.</span><span class="n">namedtuple</span><span class="p">(</span>
  104. <span class="s1">&#39;Ticket&#39;</span><span class="p">,</span>
  105. <span class="p">(</span><span class="s1">&#39;operation_id&#39;</span><span class="p">,</span> <span class="s1">&#39;sequence_number&#39;</span><span class="p">,</span> <span class="s1">&#39;group&#39;</span><span class="p">,</span> <span class="s1">&#39;method&#39;</span><span class="p">,</span> <span class="s1">&#39;subscription&#39;</span><span class="p">,</span>
  106. <span class="s1">&#39;timeout&#39;</span><span class="p">,</span> <span class="s1">&#39;allowance&#39;</span><span class="p">,</span> <span class="s1">&#39;initial_metadata&#39;</span><span class="p">,</span> <span class="s1">&#39;payload&#39;</span><span class="p">,</span>
  107. <span class="s1">&#39;terminal_metadata&#39;</span><span class="p">,</span> <span class="s1">&#39;code&#39;</span><span class="p">,</span> <span class="s1">&#39;message&#39;</span><span class="p">,</span> <span class="s1">&#39;termination&#39;</span><span class="p">,</span> <span class="s1">&#39;protocol&#39;</span><span class="p">,))):</span>
  108. <span class="sd">&quot;&quot;&quot;A sum type for all values sent from a front to a back.</span>
  109. <span class="sd"> Attributes:</span>
  110. <span class="sd"> operation_id: A unique-with-respect-to-equality hashable object identifying</span>
  111. <span class="sd"> a particular operation.</span>
  112. <span class="sd"> sequence_number: A zero-indexed integer sequence number identifying the</span>
  113. <span class="sd"> ticket&#39;s place in the stream of tickets sent in one direction for the</span>
  114. <span class="sd"> particular operation.</span>
  115. <span class="sd"> group: The group to which the method of the operation belongs. Must be</span>
  116. <span class="sd"> present in the first ticket from invocation side to service side. Ignored</span>
  117. <span class="sd"> for all other tickets exchanged during the operation.</span>
  118. <span class="sd"> method: The name of an operation. Must be present in the first ticket from</span>
  119. <span class="sd"> invocation side to service side. Ignored for all other tickets exchanged</span>
  120. <span class="sd"> during the operation.</span>
  121. <span class="sd"> subscription: A Subscription value describing the interest one side has in</span>
  122. <span class="sd"> receiving information from the other side. Must be present in the first</span>
  123. <span class="sd"> ticket from either side. Ignored for all other tickets exchanged during</span>
  124. <span class="sd"> the operation.</span>
  125. <span class="sd"> timeout: A nonzero length of time (measured from the beginning of the</span>
  126. <span class="sd"> operation) to allow for the entire operation. Must be present in the first</span>
  127. <span class="sd"> ticket from invocation side to service side. Optional for all other</span>
  128. <span class="sd"> tickets exchanged during the operation. Receipt of a value from the other</span>
  129. <span class="sd"> side of the operation indicates the value in use by that side. Setting a</span>
  130. <span class="sd"> value on a later ticket allows either side to request time extensions (or</span>
  131. <span class="sd"> even time reductions!) on in-progress operations.</span>
  132. <span class="sd"> allowance: A positive integer granting permission for a number of payloads</span>
  133. <span class="sd"> to be transmitted to the communicating side of the operation, or None if</span>
  134. <span class="sd"> no additional allowance is being granted with this ticket.</span>
  135. <span class="sd"> initial_metadata: An optional metadata value communicated from one side to</span>
  136. <span class="sd"> the other at the beginning of the operation. May be non-None in at most</span>
  137. <span class="sd"> one ticket from each side. Any non-None value must appear no later than</span>
  138. <span class="sd"> the first payload value.</span>
  139. <span class="sd"> payload: A customer payload object. May be None.</span>
  140. <span class="sd"> terminal_metadata: A metadata value comminicated from one side to the other</span>
  141. <span class="sd"> at the end of the operation. May be non-None in the same ticket as</span>
  142. <span class="sd"> the code and message, but must be None for all earlier tickets.</span>
  143. <span class="sd"> code: A value communicated at operation completion. May be None.</span>
  144. <span class="sd"> message: A value communicated at operation completion. May be None.</span>
  145. <span class="sd"> termination: A Termination value describing the end of the operation, or</span>
  146. <span class="sd"> None if the operation has not yet terminated. If set, no further tickets</span>
  147. <span class="sd"> may be sent in the same direction.</span>
  148. <span class="sd"> protocol: A Protocol value or None, with further semantics being a matter</span>
  149. <span class="sd"> between high-level application and underlying ticket transport.</span>
  150. <span class="sd"> &quot;&quot;&quot;</span>
  151. <span class="nd">@enum</span><span class="o">.</span><span class="n">unique</span>
  152. <div class="viewcode-block" id="Ticket.Subscription"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.links.html#grpc.framework.interfaces.links.links.Ticket.Subscription">[docs]</a> <span class="k">class</span> <span class="nc">Subscription</span><span class="p">(</span><span class="n">enum</span><span class="o">.</span><span class="n">Enum</span><span class="p">):</span>
  153. <span class="sd">&quot;&quot;&quot;Identifies the level of subscription of a side of an operation.&quot;&quot;&quot;</span>
  154. <span class="n">NONE</span> <span class="o">=</span> <span class="s1">&#39;none&#39;</span>
  155. <span class="n">TERMINATION</span> <span class="o">=</span> <span class="s1">&#39;termination&#39;</span>
  156. <span class="n">FULL</span> <span class="o">=</span> <span class="s1">&#39;full&#39;</span></div>
  157. <span class="nd">@enum</span><span class="o">.</span><span class="n">unique</span>
  158. <div class="viewcode-block" id="Ticket.Termination"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.links.html#grpc.framework.interfaces.links.links.Ticket.Termination">[docs]</a> <span class="k">class</span> <span class="nc">Termination</span><span class="p">(</span><span class="n">enum</span><span class="o">.</span><span class="n">Enum</span><span class="p">):</span>
  159. <span class="sd">&quot;&quot;&quot;Identifies the termination of an operation.&quot;&quot;&quot;</span>
  160. <span class="n">COMPLETION</span> <span class="o">=</span> <span class="s1">&#39;completion&#39;</span>
  161. <span class="n">CANCELLATION</span> <span class="o">=</span> <span class="s1">&#39;cancellation&#39;</span>
  162. <span class="n">EXPIRATION</span> <span class="o">=</span> <span class="s1">&#39;expiration&#39;</span>
  163. <span class="n">SHUTDOWN</span> <span class="o">=</span> <span class="s1">&#39;shutdown&#39;</span>
  164. <span class="n">RECEPTION_FAILURE</span> <span class="o">=</span> <span class="s1">&#39;reception failure&#39;</span>
  165. <span class="n">TRANSMISSION_FAILURE</span> <span class="o">=</span> <span class="s1">&#39;transmission failure&#39;</span>
  166. <span class="n">LOCAL_FAILURE</span> <span class="o">=</span> <span class="s1">&#39;local failure&#39;</span>
  167. <span class="n">REMOTE_FAILURE</span> <span class="o">=</span> <span class="s1">&#39;remote failure&#39;</span></div></div>
  168. <div class="viewcode-block" id="Link"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.links.html#grpc.framework.interfaces.links.links.Link">[docs]</a><span class="k">class</span> <span class="nc">Link</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  169. <span class="sd">&quot;&quot;&quot;Accepts and emits tickets.&quot;&quot;&quot;</span>
  170. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span>
  171. <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
  172. <div class="viewcode-block" id="Link.accept_ticket"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.links.html#grpc.framework.interfaces.links.links.Link.accept_ticket">[docs]</a> <span class="k">def</span> <span class="nf">accept_ticket</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ticket</span><span class="p">):</span>
  173. <span class="sd">&quot;&quot;&quot;Accept a Ticket.</span>
  174. <span class="sd"> Args:</span>
  175. <span class="sd"> ticket: Any Ticket.</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="Link.join_link"><a class="viewcode-back" href="../../../../../grpc.framework.interfaces.links.html#grpc.framework.interfaces.links.links.Link.join_link">[docs]</a> <span class="k">def</span> <span class="nf">join_link</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">link</span><span class="p">):</span>
  180. <span class="sd">&quot;&quot;&quot;Mates this object with a peer with which it will exchange tickets.&quot;&quot;&quot;</span>
  181. <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div></div>
  182. </pre></div>
  183. </div>
  184. </div>
  185. <footer>
  186. <hr/>
  187. <div role="contentinfo">
  188. <p>
  189. &copy; Copyright 2016, Author.
  190. </p>
  191. </div>
  192. 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>.
  193. </footer>
  194. </div>
  195. </div>
  196. </section>
  197. </div>
  198. <script type="text/javascript">
  199. var DOCUMENTATION_OPTIONS = {
  200. URL_ROOT:'../../../../../',
  201. VERSION:'0.13.1rc1',
  202. COLLAPSE_INDEX:false,
  203. FILE_SUFFIX:'.html',
  204. HAS_SOURCE: true
  205. };
  206. </script>
  207. <script type="text/javascript" src="../../../../../_static/jquery.js"></script>
  208. <script type="text/javascript" src="../../../../../_static/underscore.js"></script>
  209. <script type="text/javascript" src="../../../../../_static/doctools.js"></script>
  210. <script type="text/javascript" src="../../../../../_static/js/theme.js"></script>
  211. <script type="text/javascript">
  212. jQuery(function () {
  213. SphinxRtdTheme.StickyNav.enable();
  214. });
  215. </script>
  216. </body>
  217. </html>