module-src_server-Server.html 17 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Class: Server</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Class: Server</h1>
  17. <section>
  18. <header>
  19. <h2>
  20. <span class="ancestors"><a href="module-src_server.html">src/server</a>~</span>Server</h2>
  21. </header>
  22. <article>
  23. <div class="container-overview">
  24. <h4 class="name" id="Server"><span class="type-signature"></span>new Server<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
  25. <div class="description">
  26. Constructs a server object that stores request handlers and delegates
  27. incoming requests to those handlers
  28. </div>
  29. <h5>Parameters:</h5>
  30. <table class="params">
  31. <thead>
  32. <tr>
  33. <th>Name</th>
  34. <th>Type</th>
  35. <th>Attributes</th>
  36. <th class="last">Description</th>
  37. </tr>
  38. </thead>
  39. <tbody>
  40. <tr>
  41. <td class="name"><code>options</code></td>
  42. <td class="type">
  43. <span class="param-type">Object</span>
  44. </td>
  45. <td class="attributes">
  46. &lt;optional><br>
  47. </td>
  48. <td class="description last">Options that should be passed to the internal server
  49. implementation</td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. <dl class="details">
  54. <dt class="tag-source">Source:</dt>
  55. <dd class="tag-source"><ul class="dummy"><li>
  56. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line597">line 597</a>
  57. </li></ul></dd>
  58. </dl>
  59. </div>
  60. <h3 class="subsection-title">Methods</h3>
  61. <h4 class="name" id="addProtoService"><span class="type-signature"></span>addProtoService<span class="signature">(service, implementation)</span><span class="type-signature"></span></h4>
  62. <div class="description">
  63. Add a proto service to the server, with a corresponding implementation
  64. </div>
  65. <h5>Parameters:</h5>
  66. <table class="params">
  67. <thead>
  68. <tr>
  69. <th>Name</th>
  70. <th>Type</th>
  71. <th class="last">Description</th>
  72. </tr>
  73. </thead>
  74. <tbody>
  75. <tr>
  76. <td class="name"><code>service</code></td>
  77. <td class="type">
  78. <span class="param-type">Protobuf.Reflect.Service</span>
  79. </td>
  80. <td class="description last">The proto service descriptor</td>
  81. </tr>
  82. <tr>
  83. <td class="name"><code>implementation</code></td>
  84. <td class="type">
  85. <span class="param-type">Object.&lt;String, function()></span>
  86. </td>
  87. <td class="description last">Map of method names to
  88. method implementation for the provided service.</td>
  89. </tr>
  90. </tbody>
  91. </table>
  92. <dl class="details">
  93. <dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>Use grpc.load and Server#addService instead</li></ul></dd>
  94. <dt class="tag-source">Source:</dt>
  95. <dd class="tag-source"><ul class="dummy"><li>
  96. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line789">line 789</a>
  97. </li></ul></dd>
  98. </dl>
  99. <h4 class="name" id="addService"><span class="type-signature"></span>addService<span class="signature">(service, implementation)</span><span class="type-signature"></span></h4>
  100. <div class="description">
  101. Add a service to the server, with a corresponding implementation. If you are
  102. generating this from a proto file, you should instead use
  103. addProtoService.
  104. </div>
  105. <h5>Parameters:</h5>
  106. <table class="params">
  107. <thead>
  108. <tr>
  109. <th>Name</th>
  110. <th>Type</th>
  111. <th class="last">Description</th>
  112. </tr>
  113. </thead>
  114. <tbody>
  115. <tr>
  116. <td class="name"><code>service</code></td>
  117. <td class="type">
  118. <span class="param-type">Object.&lt;String, *></span>
  119. </td>
  120. <td class="description last">The service descriptor, as
  121. module:src/common.getProtobufServiceAttrs returns</td>
  122. </tr>
  123. <tr>
  124. <td class="name"><code>implementation</code></td>
  125. <td class="type">
  126. <span class="param-type">Object.&lt;String, function()></span>
  127. </td>
  128. <td class="description last">Map of method names to
  129. method implementation for the provided service.</td>
  130. </tr>
  131. </tbody>
  132. </table>
  133. <dl class="details">
  134. <dt class="tag-source">Source:</dt>
  135. <dd class="tag-source"><ul class="dummy"><li>
  136. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line730">line 730</a>
  137. </li></ul></dd>
  138. </dl>
  139. <h4 class="name" id="bind"><span class="type-signature"></span>bind<span class="signature">(port, creds<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
  140. <div class="description">
  141. Binds the server to the given port, with SSL enabled if creds is given
  142. </div>
  143. <h5>Parameters:</h5>
  144. <table class="params">
  145. <thead>
  146. <tr>
  147. <th>Name</th>
  148. <th>Type</th>
  149. <th>Attributes</th>
  150. <th class="last">Description</th>
  151. </tr>
  152. </thead>
  153. <tbody>
  154. <tr>
  155. <td class="name"><code>port</code></td>
  156. <td class="type">
  157. <span class="param-type">string</span>
  158. </td>
  159. <td class="attributes">
  160. </td>
  161. <td class="description last">The port that the server should bind on, in the format
  162. "address:port"</td>
  163. </tr>
  164. <tr>
  165. <td class="name"><code>creds</code></td>
  166. <td class="type">
  167. <span class="param-type"><a href="global.html#ServerCredentials">ServerCredentials</a></span>
  168. </td>
  169. <td class="attributes">
  170. &lt;optional><br>
  171. </td>
  172. <td class="description last">Server credential object to be used for
  173. SSL. Pass an insecure credentials object for an insecure port.</td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. <dl class="details">
  178. <dt class="tag-source">Source:</dt>
  179. <dd class="tag-source"><ul class="dummy"><li>
  180. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line818">line 818</a>
  181. </li></ul></dd>
  182. </dl>
  183. <h4 class="name" id="forceShutdown"><span class="type-signature"></span>forceShutdown<span class="signature">()</span><span class="type-signature"></span></h4>
  184. <div class="description">
  185. Forcibly shuts down the server. The server will stop receiving new calls
  186. and cancel all pending calls. When it returns, the server has shut down.
  187. This method is idempotent with itself and tryShutdown, and it will trigger
  188. any outstanding tryShutdown callbacks.
  189. </div>
  190. <dl class="details">
  191. <dt class="tag-source">Source:</dt>
  192. <dd class="tag-source"><ul class="dummy"><li>
  193. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line669">line 669</a>
  194. </li></ul></dd>
  195. </dl>
  196. <h4 class="name" id="register"><span class="type-signature"></span>register<span class="signature">(name, handler, serialize, deserialize, type)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
  197. <div class="description">
  198. Registers a handler to handle the named method. Fails if there already is
  199. a handler for the given method. Returns true on success
  200. </div>
  201. <h5>Parameters:</h5>
  202. <table class="params">
  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>name</code></td>
  213. <td class="type">
  214. <span class="param-type">string</span>
  215. </td>
  216. <td class="description last">The name of the method that the provided function should
  217. handle/respond to.</td>
  218. </tr>
  219. <tr>
  220. <td class="name"><code>handler</code></td>
  221. <td class="type">
  222. <span class="param-type">function</span>
  223. </td>
  224. <td class="description last">Function that takes a stream of request values and
  225. returns a stream of response values</td>
  226. </tr>
  227. <tr>
  228. <td class="name"><code>serialize</code></td>
  229. <td class="type">
  230. <span class="param-type">function</span>
  231. </td>
  232. <td class="description last">Serialization function for responses</td>
  233. </tr>
  234. <tr>
  235. <td class="name"><code>deserialize</code></td>
  236. <td class="type">
  237. <span class="param-type">function</span>
  238. </td>
  239. <td class="description last">Deserialization function for requests</td>
  240. </tr>
  241. <tr>
  242. <td class="name"><code>type</code></td>
  243. <td class="type">
  244. <span class="param-type">string</span>
  245. </td>
  246. <td class="description last">The streaming type of method that this handles</td>
  247. </tr>
  248. </tbody>
  249. </table>
  250. <dl class="details">
  251. <dt class="tag-source">Source:</dt>
  252. <dd class="tag-source"><ul class="dummy"><li>
  253. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line687">line 687</a>
  254. </li></ul></dd>
  255. </dl>
  256. <h5>Returns:</h5>
  257. <div class="param-desc">
  258. True if the handler was set. False if a handler was already
  259. set for that name.
  260. </div>
  261. <dl>
  262. <dt>
  263. Type
  264. </dt>
  265. <dd>
  266. <span class="param-type">boolean</span>
  267. </dd>
  268. </dl>
  269. <h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">()</span><span class="type-signature"></span></h4>
  270. <div class="description">
  271. Start the server and begin handling requests
  272. </div>
  273. <h5>This:</h5>
  274. <ul><li><a href="global.html#Server">Server</a></li></ul>
  275. <dl class="details">
  276. <dt class="tag-source">Source:</dt>
  277. <dd class="tag-source"><ul class="dummy"><li>
  278. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line607">line 607</a>
  279. </li></ul></dd>
  280. </dl>
  281. <h4 class="name" id="tryShutdown"><span class="type-signature"></span>tryShutdown<span class="signature">(callback)</span><span class="type-signature"></span></h4>
  282. <div class="description">
  283. Gracefully shuts down the server. The server will stop receiving new calls,
  284. and any pending calls will complete. The callback will be called when all
  285. pending calls have completed and the server is fully shut down. This method
  286. is idempotent with itself and forceShutdown.
  287. </div>
  288. <h5>Parameters:</h5>
  289. <table class="params">
  290. <thead>
  291. <tr>
  292. <th>Name</th>
  293. <th>Type</th>
  294. <th class="last">Description</th>
  295. </tr>
  296. </thead>
  297. <tbody>
  298. <tr>
  299. <td class="name"><code>callback</code></td>
  300. <td class="type">
  301. <span class="param-type">function</span>
  302. </td>
  303. <td class="description last">The shutdown complete callback</td>
  304. </tr>
  305. </tbody>
  306. </table>
  307. <dl class="details">
  308. <dt class="tag-source">Source:</dt>
  309. <dd class="tag-source"><ul class="dummy"><li>
  310. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line659">line 659</a>
  311. </li></ul></dd>
  312. </dl>
  313. </article>
  314. </section>
  315. </div>
  316. <nav>
  317. <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-src_client.html">src/client</a></li><li><a href="module-src_common.html">src/common</a></li><li><a href="module-src_credentials.html">src/credentials</a></li><li><a href="module-src_metadata.html">src/metadata</a></li><li><a href="module-src_server.html">src/server</a></li></ul><h3>Classes</h3><ul><li><a href="module-src_client.makeClientConstructor-Client.html">Client</a></li><li><a href="module-src_client-ClientDuplexStream.html">ClientDuplexStream</a></li><li><a href="module-src_client-ClientReadableStream.html">ClientReadableStream</a></li><li><a href="module-src_client-ClientWritableStream.html">ClientWritableStream</a></li><li><a href="module-src_metadata-Metadata.html">Metadata</a></li><li><a href="module-src_server-Server.html">Server</a></li><li><a href="module-src_server-ServerDuplexStream.html">ServerDuplexStream</a></li><li><a href="module-src_server-ServerReadableStream.html">ServerReadableStream</a></li><li><a href="module-src_server-ServerWritableStream.html">ServerWritableStream</a></li></ul><h3>Global</h3><ul><li><a href="global.html#callError">callError</a></li><li><a href="global.html#credentials">credentials</a></li><li><a href="global.html#deserializeCls">deserializeCls</a></li><li><a href="global.html#fullyQualifiedName">fullyQualifiedName</a></li><li><a href="global.html#getClientChannel">getClientChannel</a></li><li><a href="global.html#getProtobufServiceAttrs">getProtobufServiceAttrs</a></li><li><a href="global.html#isProbablyProtobufJs5">isProbablyProtobufJs5</a></li><li><a href="global.html#isProbablyProtobufJs6">isProbablyProtobufJs6</a></li><li><a href="global.html#load">load</a></li><li><a href="global.html#loadObject">loadObject</a></li><li><a href="global.html#logVerbosity">logVerbosity</a></li><li><a href="global.html#makeGenericClientConstructor">makeGenericClientConstructor</a></li><li><a href="global.html#Metadata">Metadata</a></li><li><a href="global.html#propagate">propagate</a></li><li><a href="global.html#serializeCls">serializeCls</a></li><li><a href="global.html#Server">Server</a></li><li><a href="global.html#ServerCredentials">ServerCredentials</a></li><li><a href="global.html#setLogger">setLogger</a></li><li><a href="global.html#setLogVerbosity">setLogVerbosity</a></li><li><a href="global.html#status">status</a></li><li><a href="global.html#waitForClientReady">waitForClientReady</a></li><li><a href="global.html#writeFlags">writeFlags</a></li></ul>
  318. </nav>
  319. <br class="clear">
  320. <footer>
  321. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Thu Apr 27 2017 17:35:39 GMT-0700 (PDT)
  322. </footer>
  323. <script> prettyPrint(); </script>
  324. <script src="scripts/linenumber.js"> </script>
  325. </body>
  326. </html>