123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <!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 Objective-C: src/objective-c/GRPCClient/GRPCInterceptor.h File Reference</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 Objective-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 id="nav-path" class="navpath">
- <ul>
- <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_4cd61089102e4513f03798aaef5eda59.html">objective-c</a></li><li class="navelem"><a class="el" href="dir_5cc52d91eb5c710f2aae2973ec7ec56c.html">GRPCClient</a></li> </ul>
- </div>
- </div><!-- top -->
- <div class="header">
- <div class="summary">
- <a href="#nested-classes">Data Structures</a> </div>
- <div class="headertitle">
- <div class="title">GRPCInterceptor.h File Reference</div> </div>
- </div><!--header-->
- <div class="contents">
- <div class="textblock"><code>#import "<a class="el" href="_g_r_p_c_call_8h_source.html">GRPCCall.h</a>"</code><br />
- <code>#import "<a class="el" href="_g_r_p_c_dispatchable_8h_source.html">GRPCDispatchable.h</a>"</code><br />
- </div>
- <p><a href="_g_r_p_c_interceptor_8h_source.html">Go to the source code of this file.</a></p>
- <table class="memberdecls">
- <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
- Data Structures</h2></td></tr>
- <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">protocol  </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_g_r_p_c_interceptor_interface-p.html"><GRPCInterceptorInterface></a></td></tr>
- <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">The <a class="el" href="protocol_g_r_p_c_interceptor_interface-p.html" title="The GRPCInterceptorInterface defines the request events that can occur to an interceptor.">GRPCInterceptorInterface</a> defines the request events that can occur to an interceptor. <a href="protocol_g_r_p_c_interceptor_interface-p.html#details">More...</a><br /></td></tr>
- <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">protocol  </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_g_r_p_c_interceptor_factory-p.html"><GRPCInterceptorFactory></a></td></tr>
- <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">An interceptor factory object is used to create interceptor object for the call at the call start time. <a href="protocol_g_r_p_c_interceptor_factory-p.html#details">More...</a><br /></td></tr>
- <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="interface_g_r_p_c_interceptor_manager.html">GRPCInterceptorManager</a></td></tr>
- <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="interface_g_r_p_c_interceptor_manager.html" title="GRPCInterceptorManager is a helper class to forward messages between the interceptors.">GRPCInterceptorManager</a> is a helper class to forward messages between the interceptors. <a href="interface_g_r_p_c_interceptor_manager.html#details">More...</a><br /></td></tr>
- <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="interface_g_r_p_c_interceptor.html">GRPCInterceptor</a></td></tr>
- <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Base class for a gRPC interceptor. <a href="interface_g_r_p_c_interceptor.html#details">More...</a><br /></td></tr>
- <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
- </table>
- <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
- <div class="textblock"><p>API for interceptors implementation. This feature is currently EXPERIMENTAL and is subject to breaking changes without prior notice.</p>
- <p>The interceptors in the gRPC system forms a chain. When a call is made by the user, each interceptor on the chain has chances to react to events of the call and make necessary modifications to the call's parameters, data, metadata, or flow.</p>
- <pre class="fragment"> -----------
- | GRPCCall2 |
- -----------
- |
- |
- --------------------------
- | GRPCInterceptorManager 1 |
- --------------------------
- | GRPCInterceptor 1 |
- --------------------------
- |
- ...
- |
- --------------------------
- | GRPCInterceptorManager N |
- --------------------------
- | GRPCInterceptor N |
- --------------------------
- |
- |
- ------------------
- | GRPCCallInternal |
- ------------------
- </pre><p>The chain of interceptors is initialized when the corresponding <a class="el" href="interface_g_r_p_c_call2.html" title="A GRPCCall2 object represents an RPC call.">GRPCCall2</a> object or proto call object (<a class="el" href="interface_g_r_p_c_unary_proto_call.html" title="A unary-request RPC call with Protobuf.">GRPCUnaryProtoCall</a> and <a class="el" href="interface_g_r_p_c_streaming_proto_call.html" title="A client-streaming RPC call with Protobuf.">GRPCStreamingProtoCall</a>) is initialized. The initialization of the chain is controlled by the property interceptorFactories in the callOptions parameter of the corresponding call object. Property interceptorFactories is an array of id<GRPCInterceptorFactory> objects provided by the user. When a call object is initialized, each interceptor factory generates an interceptor object for the call. gRPC internally links the interceptors with each other and with the actual call object. The order of the interceptors in the chain is exactly the same as the order of factory objects in interceptorFactories property. All requests (start, write, finish, cancel, receive next) initiated by the user will be processed in the order of interceptors, and all responses (initial metadata, data, trailing metadata, write data done) are processed in the reverse order.</p>
- <p>Each interceptor in the interceptor chain should behave as a user of the next interceptor, and at the same time behave as a call to the previous interceptor. Therefore interceptor implementations must follow the state transition of gRPC calls and must also forward events that are consistent with the current state of the next/previous interceptor. They should also make sure that the events they forwarded to the next and previous interceptors will, in the end, make the neighbour interceptor terminate correctly and reaches "finished" state. The diagram below shows the state transitions. Any event not appearing on the diagram means the event is not permitted for that particular state.</p>
- <pre class="fragment"> writeData
- receiveNextMessages
- didReceiveInitialMetadata
- didReceiveData
- didWriteData receiveNextmessages
- writeData ----- ----- ---- didReceiveInitialMetadata
- receiveNextMessages | | | | | | didReceiveData
- | V | V | V didWriteData
- ------------- start --------- finish ------------
- | initialized | -----> | started | --------> | half-close |
- ------------- --------- ------------
- | | |
- | | didClose | didClose
- |cancel | cancel | cancel
- | V |
- | ---------- |
- --------------> | finished | <--------------
- ----------
- | ^ writeData
- | | finish
- ------ cancel
- receiveNextMessages
- </pre><p>An interceptor must forward responses to its previous interceptor in the order of initial metadata, message(s), and trailing metadata. Forwarding responses out of this order (e.g. forwarding a message before initial metadata) is not allowed.</p>
- <p>Events of requests and responses are dispatched to interceptor objects using the interceptor's dispatch queue. The dispatch queue should be serial queue to make sure the events are processed in order. Interceptor implementations must derive from <a class="el" href="interface_g_r_p_c_interceptor.html" title="Base class for a gRPC interceptor.">GRPCInterceptor</a> class. The class makes some basic implementation of all methods responding to an event of a call. If an interceptor does not care about a particular event, it can use the basic implementation of the <a class="el" href="interface_g_r_p_c_interceptor.html" title="Base class for a gRPC interceptor.">GRPCInterceptor</a> class, which simply forward the event to the next or previous interceptor in the chain.</p>
- <p>The interceptor object should be unique for each call since the call context is not passed to the interceptor object in a call event. However, the interceptors can be implemented to share states by receiving state sharing object from the factory upon construction. </p>
- </div></div><!-- contents -->
- <!-- start footer part -->
- <hr class="footer"/><address class="footer"><small>
- Generated on Wed Mar 3 2021 19:20:09 for GRPC Objective-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>
|