grpc.Server.html 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>Documentation Class: Server</title>
  7. <!--[if lt IE 9]>
  8. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  9. <![endif]-->
  10. <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
  11. <link type="text/css" rel="stylesheet" href="styles/site.simplex.css">
  12. </head>
  13. <body>
  14. <div class="navbar navbar-default navbar-fixed-top ">
  15. <div class="container">
  16. <div class="navbar-header">
  17. <a class="navbar-brand" href="index.html">Documentation</a>
  18. <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
  19. <span class="icon-bar"></span>
  20. <span class="icon-bar"></span>
  21. <span class="icon-bar"></span>
  22. </button>
  23. </div>
  24. <div class="navbar-collapse collapse" id="topNavigation">
  25. <ul class="nav navbar-nav">
  26. <li class="dropdown">
  27. <a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
  28. <ul class="dropdown-menu ">
  29. <li><a href="grpc.html">grpc</a></li><li><a href="grpc.credentials.html">grpc.credentials</a></li>
  30. </ul>
  31. </li>
  32. <li class="dropdown">
  33. <a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
  34. <ul class="dropdown-menu ">
  35. <li><a href="module-src_client_interceptors.html">src/client_interceptors</a></li>
  36. </ul>
  37. </li>
  38. <li class="dropdown">
  39. <a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
  40. <ul class="dropdown-menu ">
  41. <li><a href="grpc.Channel.html">grpc.Channel</a></li><li><a href="grpc.Client.html">grpc.Client</a></li><li><a href="grpc.credentials-CallCredentials.html">grpc.credentials~CallCredentials</a></li><li><a href="grpc.credentials-ChannelCredentials.html">grpc.credentials~ChannelCredentials</a></li><li><a href="grpc.Metadata.html">grpc.Metadata</a></li><li><a href="grpc.Server.html">grpc.Server</a></li><li><a href="grpc.ServerCredentials.html">grpc.ServerCredentials</a></li><li><a href="grpc-Call.html">grpc~Call</a></li><li><a href="grpc-ClientDuplexStream.html">grpc~ClientDuplexStream</a></li><li><a href="grpc-ClientReadableStream.html">grpc~ClientReadableStream</a></li><li><a href="grpc-ClientUnaryCall.html">grpc~ClientUnaryCall</a></li><li><a href="grpc-ClientWritableStream.html">grpc~ClientWritableStream</a></li><li><a href="grpc-ServerDuplexStream.html">grpc~ServerDuplexStream</a></li><li><a href="grpc-ServerReadableStream.html">grpc~ServerReadableStream</a></li><li><a href="grpc-ServerUnaryCall.html">grpc~ServerUnaryCall</a></li><li><a href="grpc-ServerWritableStream.html">grpc~ServerWritableStream</a></li><li><a href="module-src_client_interceptors-EndListener.html">src/client_interceptors~EndListener</a></li><li><a href="module-src_client_interceptors-InterceptingCall.html">src/client_interceptors~InterceptingCall</a></li><li><a href="module-src_client_interceptors-InterceptingListener.html">src/client_interceptors~InterceptingListener</a></li><li><a href="module-src_client_interceptors-InterceptorConfigurationError.html">src/client_interceptors~InterceptorConfigurationError</a></li><li><a href="module-src_client_interceptors-ListenerBuilder.html">src/client_interceptors~ListenerBuilder</a></li><li><a href="module-src_client_interceptors-RequesterBuilder.html">src/client_interceptors~RequesterBuilder</a></li><li><a href="module-src_client_interceptors-StatusBuilder.html">src/client_interceptors~StatusBuilder</a></li>
  42. </ul>
  43. </li>
  44. <li class="dropdown">
  45. <a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
  46. <ul class="dropdown-menu ">
  47. <li><a href="grpc-ClientDuplexStream.html#event:metadata">grpc~ClientDuplexStream#metadata</a></li><li><a href="grpc-ClientDuplexStream.html#event:status">grpc~ClientDuplexStream#status</a></li><li><a href="grpc-ClientReadableStream.html#event:metadata">grpc~ClientReadableStream#metadata</a></li><li><a href="grpc-ClientReadableStream.html#event:status">grpc~ClientReadableStream#status</a></li><li><a href="grpc-ClientUnaryCall.html#event:metadata">grpc~ClientUnaryCall#event:metadata</a></li><li><a href="grpc-ClientUnaryCall.html#event:status">grpc~ClientUnaryCall#event:status</a></li><li><a href="grpc-ClientWritableStream.html#event:metadata">grpc~ClientWritableStream#metadata</a></li><li><a href="grpc-ClientWritableStream.html#event:status">grpc~ClientWritableStream#status</a></li><li><a href="grpc-ServerDuplexStream.html#~event:cancelled">grpc~ServerDuplexStream~event:cancelled</a></li><li><a href="grpc-ServerReadableStream.html#~event:cancelled">grpc~ServerReadableStream~event:cancelled</a></li><li><a href="grpc-ServerUnaryCall.html#~event:cancelled">grpc~ServerUnaryCall~event:cancelled</a></li><li><a href="grpc-ServerWritableStream.html#~event:cancelled">grpc~ServerWritableStream~event:cancelled</a></li>
  48. </ul>
  49. </li>
  50. <li class="dropdown">
  51. <a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
  52. <ul class="dropdown-menu ">
  53. <li><a href="global.html#CancelRequester">CancelRequester</a></li><li><a href="global.html#CloseRequester">CloseRequester</a></li><li><a href="global.html#createStatusError">createStatusError</a></li><li><a href="global.html#getClientInterceptors">getClientInterceptors</a></li><li><a href="global.html#getMethodType">getMethodType</a></li><li><a href="global.html#GetPeerRequester">GetPeerRequester</a></li><li><a href="global.html#Interceptor">Interceptor</a></li><li><a href="global.html#InterceptorProvider">InterceptorProvider</a></li><li><a href="global.html#loadPackageDefinition">loadPackageDefinition</a></li><li><a href="global.html#MessageListener">MessageListener</a></li><li><a href="global.html#MessageRequester">MessageRequester</a></li><li><a href="global.html#MetadataListener">MetadataListener</a></li><li><a href="global.html#MetadataRequester">MetadataRequester</a></li><li><a href="global.html#NextCall">NextCall</a></li><li><a href="global.html#StatusListener">StatusListener</a></li>
  54. </ul>
  55. </li>
  56. <li class="dropdown">
  57. <a href="externals.list.html" class="dropdown-toggle" data-toggle="dropdown">Externals<b class="caret"></b></a>
  58. <ul class="dropdown-menu ">
  59. <li><a href="external-Duplex.html">Duplex</a></li><li><a href="external-EventEmitter.html">EventEmitter</a></li><li><a href="external-GoogleCredential.html">GoogleCredential</a></li><li><a href="external-Readable.html">Readable</a></li><li><a href="external-Writable.html">Writable</a></li>
  60. </ul>
  61. </li>
  62. </ul>
  63. <div class="col-sm-3 col-md-3">
  64. <form class="navbar-form" role="search">
  65. <div class="input-group">
  66. <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
  67. <div class="input-group-btn">
  68. <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
  69. </div>
  70. </div>
  71. </form>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="container" id="toc-content">
  77. <div class="row">
  78. <div class="col-md-8">
  79. <div id="main">
  80. <h1 class="page-title">Class: Server</h1>
  81. <section>
  82. <header>
  83. <h2>
  84. <span class="ancestors"><a href="grpc.html">grpc</a>.</span>
  85. Server
  86. </h2>
  87. </header>
  88. <article>
  89. <div class="container-overview">
  90. <hr>
  91. <dt>
  92. <h4 class="name" id="Server"><span class="type-signature"></span>new Server( [options])</h4>
  93. </dt>
  94. <dd>
  95. <div class="description">
  96. <p>Constructs a server object that stores request handlers and delegates
  97. incoming requests to those handlers</p>
  98. </div>
  99. <h5>Parameters:</h5>
  100. <table class="params table table-striped">
  101. <thead>
  102. <tr>
  103. <th>Name</th>
  104. <th>Type</th>
  105. <th>Argument</th>
  106. <th class="last">Description</th>
  107. </tr>
  108. </thead>
  109. <tbody>
  110. <tr>
  111. <td class="name"><code>options</code></td>
  112. <td class="type">
  113. <span class="param-type">Object</span>
  114. </td>
  115. <td class="attributes">
  116. &lt;optional><br>
  117. </td>
  118. <td class="description last"><p>Options that should be passed to the internal server
  119. implementation</p></td>
  120. </tr>
  121. </tbody>
  122. </table>
  123. <dl class="details">
  124. </dl>
  125. <h5>Example</h5>
  126. <pre class="sunlight-highlight-javascript">var server = new grpc.Server();
  127. server.addProtoService(protobuf_service_descriptor, service_implementation);
  128. server.bind(&#x27;address:port&#x27;, server_credential);
  129. server.start();</pre>
  130. </dd>
  131. </div>
  132. <h3 class="subsection-title">Members</h3>
  133. <dl>
  134. <hr>
  135. <dt class="name" id="addProtoService">
  136. <h4 id="addProtoService"><span class="type-signature"></span>addProtoService<span class="type-signature"></span></h4>
  137. </dt>
  138. <dd>
  139. <div class="description">
  140. <p>Add a proto service to the server, with a corresponding implementation</p>
  141. </div>
  142. <dl class="details">
  143. <dt class="important tag-deprecated method-doc-label method-doc-details-label">Deprecated:</dt>
  144. <dd>
  145. <ul class="dummy">
  146. <li>Use <a href="grpc.Server.html#addService">grpc.Server#addService</a> instead</li>
  147. </ul>
  148. </dd>
  149. </dl>
  150. </dd>
  151. </dl>
  152. <h3 class="subsection-title">Methods</h3>
  153. <dl>
  154. <hr>
  155. <dt>
  156. <h4 class="name" id="addService"><span class="type-signature"></span>addService(service, implementation)</h4>
  157. </dt>
  158. <dd>
  159. <div class="description">
  160. <p>Add a service to the server, with a corresponding implementation.</p>
  161. </div>
  162. <h5>Parameters:</h5>
  163. <table class="params table table-striped">
  164. <thead>
  165. <tr>
  166. <th>Name</th>
  167. <th>Type</th>
  168. <th class="last">Description</th>
  169. </tr>
  170. </thead>
  171. <tbody>
  172. <tr>
  173. <td class="name"><code>service</code></td>
  174. <td class="type">
  175. <span class="param-type"><a href="grpc.html#~ServiceDefinition">grpc~ServiceDefinition</a></span>
  176. </td>
  177. <td class="description last"><p>The service descriptor</p></td>
  178. </tr>
  179. <tr>
  180. <td class="name"><code>implementation</code></td>
  181. <td class="type">
  182. <span class="param-type">Object.&lt;String, <a href="grpc.Server.html#~handleCall">grpc.Server~handleCall</a>></span>
  183. </td>
  184. <td class="description last"><p>Map of method
  185. names to method implementation for the provided service.</p></td>
  186. </tr>
  187. </tbody>
  188. </table>
  189. <dl class="details">
  190. </dl>
  191. </dd>
  192. <hr>
  193. <dt>
  194. <h4 class="name" id="bind"><span class="type-signature"></span>bind(port, creds)</h4>
  195. </dt>
  196. <dd>
  197. <div class="description">
  198. <p>Binds the server to the given port, with SSL disabled if creds is an
  199. insecure credentials object</p>
  200. </div>
  201. <h5>Parameters:</h5>
  202. <table class="params table table-striped">
  203. <thead>
  204. <tr>
  205. <th>Name</th>
  206. <th>Type</th>
  207. <th class="last">Description</th>
  208. </tr>
  209. </thead>
  210. <tbody>
  211. <tr>
  212. <td class="name"><code>port</code></td>
  213. <td class="type">
  214. <span class="param-type">string</span>
  215. </td>
  216. <td class="description last"><p>The port that the server should bind on, in the format
  217. &quot;address:port&quot;</p></td>
  218. </tr>
  219. <tr>
  220. <td class="name"><code>creds</code></td>
  221. <td class="type">
  222. <span class="param-type"><a href="grpc.ServerCredentials.html">grpc.ServerCredentials</a></span>
  223. </td>
  224. <td class="description last"><p>Server credential object to be used for
  225. SSL. Pass an insecure credentials object for an insecure port.</p></td>
  226. </tr>
  227. </tbody>
  228. </table>
  229. <dl class="details">
  230. </dl>
  231. <h5>Returns:</h5>
  232. <div class="param-desc">
  233. <p>The bound port number. Negative if binding the port failed.</p>
  234. </div>
  235. <dl>
  236. <dt>
  237. Type
  238. </dt>
  239. <dd>
  240. <span class="param-type">number</span>
  241. </dd>
  242. </dl>
  243. </dd>
  244. <hr>
  245. <dt>
  246. <h4 class="name" id="bindAsync"><span class="type-signature"></span>bindAsync(port, creds)</h4>
  247. </dt>
  248. <dd>
  249. <div class="description">
  250. <p>Binds the server to the given port, with SSL disabled if creds is an
  251. insecure credentials object. Provides the result asynchronously.</p>
  252. </div>
  253. <h5>Parameters:</h5>
  254. <table class="params table table-striped">
  255. <thead>
  256. <tr>
  257. <th>Name</th>
  258. <th>Type</th>
  259. <th class="last">Description</th>
  260. </tr>
  261. </thead>
  262. <tbody>
  263. <tr>
  264. <td class="name"><code>port</code></td>
  265. <td class="type">
  266. <span class="param-type">string</span>
  267. </td>
  268. <td class="description last"><p>The port that the server should bind on, in the format
  269. &quot;address:port&quot;</p></td>
  270. </tr>
  271. <tr>
  272. <td class="name"><code>creds</code></td>
  273. <td class="type">
  274. <span class="param-type"><a href="grpc.ServerCredentials.html">grpc.ServerCredentials</a></span>
  275. </td>
  276. <td class="description last"><p>Server credential object to be used for
  277. SSL. Pass an insecure credentials object for an insecure port.</p></td>
  278. </tr>
  279. </tbody>
  280. </table>
  281. <dl class="details">
  282. </dl>
  283. </dd>
  284. <hr>
  285. <dt>
  286. <h4 class="name" id="forceShutdown"><span class="type-signature"></span>forceShutdown()</h4>
  287. </dt>
  288. <dd>
  289. <div class="description">
  290. <p>Forcibly shuts down the server. The server will stop receiving new calls
  291. and cancel all pending calls. When it returns, the server has shut down.
  292. This method is idempotent with itself and tryShutdown, and it will trigger
  293. any outstanding tryShutdown callbacks.</p>
  294. </div>
  295. <dl class="details">
  296. </dl>
  297. </dd>
  298. <hr>
  299. <dt>
  300. <h4 class="name" id="register"><span class="type-signature"></span>register(name, handler, serialize, deserialize, type)</h4>
  301. </dt>
  302. <dd>
  303. <div class="description">
  304. <p>Registers a handler to handle the named method. Fails if there already is
  305. a handler for the given method. Returns true on success</p>
  306. </div>
  307. <h5>Parameters:</h5>
  308. <table class="params table table-striped">
  309. <thead>
  310. <tr>
  311. <th>Name</th>
  312. <th>Type</th>
  313. <th class="last">Description</th>
  314. </tr>
  315. </thead>
  316. <tbody>
  317. <tr>
  318. <td class="name"><code>name</code></td>
  319. <td class="type">
  320. <span class="param-type">string</span>
  321. </td>
  322. <td class="description last"><p>The name of the method that the provided function should
  323. handle/respond to.</p></td>
  324. </tr>
  325. <tr>
  326. <td class="name"><code>handler</code></td>
  327. <td class="type">
  328. <span class="param-type"><a href="grpc.Server.html#~handleCall">grpc.Server~handleCall</a></span>
  329. </td>
  330. <td class="description last"><p>Function that takes a stream of
  331. request values and returns a stream of response values</p></td>
  332. </tr>
  333. <tr>
  334. <td class="name"><code>serialize</code></td>
  335. <td class="type">
  336. <span class="param-type"><a href="grpc.html#~serialize">grpc~serialize</a></span>
  337. </td>
  338. <td class="description last"><p>Serialization function for responses</p></td>
  339. </tr>
  340. <tr>
  341. <td class="name"><code>deserialize</code></td>
  342. <td class="type">
  343. <span class="param-type"><a href="grpc.html#~deserialize">grpc~deserialize</a></span>
  344. </td>
  345. <td class="description last"><p>Deserialization function for requests</p></td>
  346. </tr>
  347. <tr>
  348. <td class="name"><code>type</code></td>
  349. <td class="type">
  350. <span class="param-type">'unary'</span>
  351. |
  352. <span class="param-type">'client_stream'</span>
  353. |
  354. <span class="param-type">'server_stream'</span>
  355. |
  356. <span class="param-type">'bidi'</span>
  357. </td>
  358. <td class="description last"><p>The streaming type of method that this handles</p></td>
  359. </tr>
  360. </tbody>
  361. </table>
  362. <dl class="details">
  363. </dl>
  364. <h5>Returns:</h5>
  365. <div class="param-desc">
  366. <p>True if the handler was set. False if a handler was already
  367. set for that name.</p>
  368. </div>
  369. <dl>
  370. <dt>
  371. Type
  372. </dt>
  373. <dd>
  374. <span class="param-type">boolean</span>
  375. </dd>
  376. </dl>
  377. </dd>
  378. <hr>
  379. <dt>
  380. <h4 class="name" id="start"><span class="type-signature"></span>start()</h4>
  381. </dt>
  382. <dd>
  383. <div class="description">
  384. <p>Start the server and begin handling requests</p>
  385. </div>
  386. <dl class="details">
  387. </dl>
  388. </dd>
  389. <hr>
  390. <dt>
  391. <h4 class="name" id="tryShutdown"><span class="type-signature"></span>tryShutdown(callback)</h4>
  392. </dt>
  393. <dd>
  394. <div class="description">
  395. <p>Gracefully shuts down the server. The server will stop receiving new calls,
  396. and any pending calls will complete. The callback will be called when all
  397. pending calls have completed and the server is fully shut down. This method
  398. is idempotent with itself and forceShutdown.</p>
  399. </div>
  400. <h5>Parameters:</h5>
  401. <table class="params table table-striped">
  402. <thead>
  403. <tr>
  404. <th>Name</th>
  405. <th>Type</th>
  406. <th class="last">Description</th>
  407. </tr>
  408. </thead>
  409. <tbody>
  410. <tr>
  411. <td class="name"><code>callback</code></td>
  412. <td class="type">
  413. <span class="param-type">function</span>
  414. </td>
  415. <td class="description last"><p>The shutdown complete callback</p></td>
  416. </tr>
  417. </tbody>
  418. </table>
  419. <dl class="details">
  420. </dl>
  421. </dd>
  422. </dl>
  423. <h3 class="subsection-title">Type Definitions</h3>
  424. <dl>
  425. <hr>
  426. <dt>
  427. <h4 class="name" id="~bindCallback"><span class="type-signature"></span>bindCallback( [error], port)</h4>
  428. </dt>
  429. <dd>
  430. <div class="description">
  431. <p>Called with the result of attempting to bind a port</p>
  432. </div>
  433. <h5>Parameters:</h5>
  434. <table class="params table table-striped">
  435. <thead>
  436. <tr>
  437. <th>Name</th>
  438. <th>Type</th>
  439. <th>Argument</th>
  440. <th class="last">Description</th>
  441. </tr>
  442. </thead>
  443. <tbody>
  444. <tr>
  445. <td class="name"><code>error</code></td>
  446. <td class="type">
  447. <span class="param-type">Error</span>
  448. </td>
  449. <td class="attributes">
  450. &lt;optional><br>
  451. </td>
  452. <td class="description last"><p>If non-null, indicates that binding the port failed.</p></td>
  453. </tr>
  454. <tr>
  455. <td class="name"><code>port</code></td>
  456. <td class="type">
  457. <span class="param-type">number</span>
  458. </td>
  459. <td class="attributes">
  460. </td>
  461. <td class="description last"><p>The bound port number. If binding the port fails, this
  462. will be negative to match the output of bind.</p></td>
  463. </tr>
  464. </tbody>
  465. </table>
  466. <dl class="details">
  467. </dl>
  468. </dd>
  469. <hr>
  470. <dt>
  471. <h4 class="name" id="~handleBidiStreamingCall"><span class="type-signature"></span>handleBidiStreamingCall(call)</h4>
  472. </dt>
  473. <dd>
  474. <div class="description">
  475. <p>User provided method to handle bidirectional streaming calls on the server.</p>
  476. </div>
  477. <h5>Parameters:</h5>
  478. <table class="params table table-striped">
  479. <thead>
  480. <tr>
  481. <th>Name</th>
  482. <th>Type</th>
  483. <th class="last">Description</th>
  484. </tr>
  485. </thead>
  486. <tbody>
  487. <tr>
  488. <td class="name"><code>call</code></td>
  489. <td class="type">
  490. <span class="param-type"><a href="grpc-ServerDuplexStream.html">grpc~ServerDuplexStream</a></span>
  491. </td>
  492. <td class="description last"><p>The call object</p></td>
  493. </tr>
  494. </tbody>
  495. </table>
  496. <dl class="details">
  497. </dl>
  498. </dd>
  499. <hr>
  500. <dt class="name" id="~handleCall">
  501. <h4 id="~handleCall">handleCall</h4>
  502. </dt>
  503. <dd>
  504. <div class="description">
  505. <p>Unified type for application handlers for all types of calls</p>
  506. </div>
  507. <h5>Type:</h5>
  508. <ul>
  509. <li>
  510. <span class="param-type"><a href="grpc.Server.html#~handleUnaryCall">grpc.Server~handleUnaryCall</a></span>
  511. |
  512. <span class="param-type"><a href="grpc.Server.html#~handleClientStreamingCall">grpc.Server~handleClientStreamingCall</a></span>
  513. |
  514. <span class="param-type"><a href="grpc.Server.html#~handleServerStreamingCall">grpc.Server~handleServerStreamingCall</a></span>
  515. |
  516. <span class="param-type"><a href="grpc.Server.html#~handleBidiStreamingCall">grpc.Server~handleBidiStreamingCall</a></span>
  517. </li>
  518. </ul>
  519. <dl class="details">
  520. </dl>
  521. </dd>
  522. <hr>
  523. <dt>
  524. <h4 class="name" id="~handleClientStreamingCall"><span class="type-signature"></span>handleClientStreamingCall(call, callback)</h4>
  525. </dt>
  526. <dd>
  527. <div class="description">
  528. <p>User provided method to handle client streaming methods on the server.</p>
  529. </div>
  530. <h5>Parameters:</h5>
  531. <table class="params table table-striped">
  532. <thead>
  533. <tr>
  534. <th>Name</th>
  535. <th>Type</th>
  536. <th class="last">Description</th>
  537. </tr>
  538. </thead>
  539. <tbody>
  540. <tr>
  541. <td class="name"><code>call</code></td>
  542. <td class="type">
  543. <span class="param-type"><a href="grpc-ServerReadableStream.html">grpc~ServerReadableStream</a></span>
  544. </td>
  545. <td class="description last"><p>The call object</p></td>
  546. </tr>
  547. <tr>
  548. <td class="name"><code>callback</code></td>
  549. <td class="type">
  550. <span class="param-type"><a href="grpc.Server.html#~sendUnaryData">grpc.Server~sendUnaryData</a></span>
  551. </td>
  552. <td class="description last"><p>The callback to call to respond
  553. to the request</p></td>
  554. </tr>
  555. </tbody>
  556. </table>
  557. <dl class="details">
  558. </dl>
  559. </dd>
  560. <hr>
  561. <dt>
  562. <h4 class="name" id="~handleServerStreamingCall"><span class="type-signature"></span>handleServerStreamingCall(call)</h4>
  563. </dt>
  564. <dd>
  565. <div class="description">
  566. <p>User provided method to handle server streaming methods on the server.</p>
  567. </div>
  568. <h5>Parameters:</h5>
  569. <table class="params table table-striped">
  570. <thead>
  571. <tr>
  572. <th>Name</th>
  573. <th>Type</th>
  574. <th class="last">Description</th>
  575. </tr>
  576. </thead>
  577. <tbody>
  578. <tr>
  579. <td class="name"><code>call</code></td>
  580. <td class="type">
  581. <span class="param-type"><a href="grpc-ServerWritableStream.html">grpc~ServerWritableStream</a></span>
  582. </td>
  583. <td class="description last"><p>The call object</p></td>
  584. </tr>
  585. </tbody>
  586. </table>
  587. <dl class="details">
  588. </dl>
  589. </dd>
  590. <hr>
  591. <dt>
  592. <h4 class="name" id="~handleUnaryCall"><span class="type-signature"></span>handleUnaryCall(call, callback)</h4>
  593. </dt>
  594. <dd>
  595. <div class="description">
  596. <p>User-provided method to handle unary requests on a server</p>
  597. </div>
  598. <h5>Parameters:</h5>
  599. <table class="params table table-striped">
  600. <thead>
  601. <tr>
  602. <th>Name</th>
  603. <th>Type</th>
  604. <th class="last">Description</th>
  605. </tr>
  606. </thead>
  607. <tbody>
  608. <tr>
  609. <td class="name"><code>call</code></td>
  610. <td class="type">
  611. <span class="param-type"><a href="grpc-ServerUnaryCall.html">grpc~ServerUnaryCall</a></span>
  612. </td>
  613. <td class="description last"><p>The call object</p></td>
  614. </tr>
  615. <tr>
  616. <td class="name"><code>callback</code></td>
  617. <td class="type">
  618. <span class="param-type"><a href="grpc.Server.html#~sendUnaryData">grpc.Server~sendUnaryData</a></span>
  619. </td>
  620. <td class="description last"><p>The callback to call to respond
  621. to the request</p></td>
  622. </tr>
  623. </tbody>
  624. </table>
  625. <dl class="details">
  626. </dl>
  627. </dd>
  628. <hr>
  629. <dt>
  630. <h4 class="name" id="~sendUnaryData"><span class="type-signature"></span>sendUnaryData(error, value [, trailer] [, flags])</h4>
  631. </dt>
  632. <dd>
  633. <div class="description">
  634. <p>Callback function passed to server handlers that handle methods with unary
  635. responses.</p>
  636. </div>
  637. <h5>Parameters:</h5>
  638. <table class="params table table-striped">
  639. <thead>
  640. <tr>
  641. <th>Name</th>
  642. <th>Type</th>
  643. <th>Argument</th>
  644. <th class="last">Description</th>
  645. </tr>
  646. </thead>
  647. <tbody>
  648. <tr>
  649. <td class="name"><code>error</code></td>
  650. <td class="type">
  651. <span class="param-type"><a href="grpc.html#~ServiceError">grpc~ServiceError</a></span>
  652. </td>
  653. <td class="attributes">
  654. </td>
  655. <td class="description last"><p>An error, if the call failed</p></td>
  656. </tr>
  657. <tr>
  658. <td class="name"><code>value</code></td>
  659. <td class="type">
  660. <span class="param-type">*</span>
  661. </td>
  662. <td class="attributes">
  663. </td>
  664. <td class="description last"><p>The response value. Must be a valid argument to the
  665. <code>responseSerialize</code> method of the method that is being handled</p></td>
  666. </tr>
  667. <tr>
  668. <td class="name"><code>trailer</code></td>
  669. <td class="type">
  670. <span class="param-type"><a href="grpc.Metadata.html">grpc.Metadata</a></span>
  671. </td>
  672. <td class="attributes">
  673. &lt;optional><br>
  674. </td>
  675. <td class="description last"><p>Trailing metadata to send, if applicable</p></td>
  676. </tr>
  677. <tr>
  678. <td class="name"><code>flags</code></td>
  679. <td class="type">
  680. <span class="param-type"><a href="grpc.html#.writeFlags">grpc.writeFlags</a></span>
  681. </td>
  682. <td class="attributes">
  683. &lt;optional><br>
  684. </td>
  685. <td class="description last"><p>Flags to modify writing the response</p></td>
  686. </tr>
  687. </tbody>
  688. </table>
  689. <dl class="details">
  690. </dl>
  691. </dd>
  692. </dl>
  693. </article>
  694. </section>
  695. </div>
  696. </div>
  697. <div class="clearfix"></div>
  698. <div class="col-md-3">
  699. <div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
  700. </div>
  701. </div>
  702. </div>
  703. <div class="modal fade" id="searchResults">
  704. <div class="modal-dialog">
  705. <div class="modal-content">
  706. <div class="modal-header">
  707. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  708. <h4 class="modal-title">Search results</h4>
  709. </div>
  710. <div class="modal-body"></div>
  711. <div class="modal-footer">
  712. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  713. </div>
  714. </div><!-- /.modal-content -->
  715. </div><!-- /.modal-dialog -->
  716. </div>
  717. <footer>
  718. <span class="jsdoc-message">
  719. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
  720. on 2018-11-29T11:16:28-08:00
  721. using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
  722. </span>
  723. </footer>
  724. <script src="scripts/docstrap.lib.js"></script>
  725. <script src="scripts/toc.js"></script>
  726. <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
  727. <script>
  728. $( function () {
  729. $( "[id*='$']" ).each( function () {
  730. var $this = $( this );
  731. $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
  732. } );
  733. $( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
  734. var $this = $( this );
  735. var example = $this.find( "code" );
  736. exampleText = example.html();
  737. var lang = /{@lang (.*?)}/.exec( exampleText );
  738. if ( lang && lang[1] ) {
  739. exampleText = exampleText.replace( lang[0], "" );
  740. example.html( exampleText );
  741. lang = lang[1];
  742. } else {
  743. var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
  744. lang = langClassMatch ? langClassMatch[1] : "javascript";
  745. }
  746. if ( lang ) {
  747. $this
  748. .addClass( "sunlight-highlight-" + lang )
  749. .addClass( "linenums" )
  750. .html( example.html() );
  751. }
  752. } );
  753. Sunlight.highlightAll( {
  754. lineNumbers : false,
  755. showMenu : true,
  756. enableDoclinks : true
  757. } );
  758. $.catchAnchorLinks( {
  759. navbarOffset: 10
  760. } );
  761. $( "#toc" ).toc( {
  762. anchorName : function ( i, heading, prefix ) {
  763. return $( heading ).attr( "id" ) || ( prefix + i );
  764. },
  765. selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
  766. showAndHide : false,
  767. smoothScrolling: true
  768. } );
  769. $( "#main span[id^='toc']" ).addClass( "toc-shim" );
  770. $( '.dropdown-toggle' ).dropdown();
  771. $( "table" ).each( function () {
  772. var $this = $( this );
  773. $this.addClass('table');
  774. } );
  775. } );
  776. </script>
  777. <!--Navigation and Symbol Display-->
  778. <!--Google Analytics-->
  779. <script type="text/javascript">
  780. $(document).ready(function() {
  781. SearcherDisplay.init();
  782. });
  783. </script>
  784. </body>
  785. </html>