src_common.js.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: src/common.js</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">Source: src/common.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>/**
  20. * @license
  21. * Copyright 2015 gRPC authors.
  22. *
  23. * Licensed under the Apache License, Version 2.0 (the "License");
  24. * you may not use this file except in compliance with the License.
  25. * You may obtain a copy of the License at
  26. *
  27. * http://www.apache.org/licenses/LICENSE-2.0
  28. *
  29. * Unless required by applicable law or agreed to in writing, software
  30. * distributed under the License is distributed on an "AS IS" BASIS,
  31. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  32. * See the License for the specific language governing permissions and
  33. * limitations under the License.
  34. *
  35. */
  36. 'use strict';
  37. var _ = require('lodash');
  38. /**
  39. * Wrap a function to pass null-like values through without calling it. If no
  40. * function is given, just uses the identity.
  41. * @private
  42. * @param {?function} func The function to wrap
  43. * @return {function} The wrapped function
  44. */
  45. exports.wrapIgnoreNull = function wrapIgnoreNull(func) {
  46. if (!func) {
  47. return _.identity;
  48. }
  49. return function(arg) {
  50. if (arg === null || arg === undefined) {
  51. return null;
  52. }
  53. return func(arg);
  54. };
  55. };
  56. /**
  57. * The logger object for the gRPC module. Defaults to console.
  58. * @private
  59. */
  60. exports.logger = console;
  61. /**
  62. * The current logging verbosity. 0 corresponds to logging everything
  63. * @private
  64. */
  65. exports.logVerbosity = 0;
  66. /**
  67. * Log a message if the severity is at least as high as the current verbosity
  68. * @private
  69. * @param {Number} severity A value of the grpc.logVerbosity map
  70. * @param {String} message The message to log
  71. */
  72. exports.log = function log(severity, message) {
  73. if (severity >= exports.logVerbosity) {
  74. exports.logger.error(message);
  75. }
  76. };
  77. /**
  78. * Default options for loading proto files into gRPC
  79. * @alias grpc~defaultLoadOptions
  80. */
  81. exports.defaultGrpcOptions = {
  82. convertFieldsToCamelCase: false,
  83. binaryAsBase64: false,
  84. longsAsStrings: true,
  85. enumsAsStrings: true,
  86. deprecatedArgumentOrder: false
  87. };
  88. // JSDoc definitions that are used in multiple other modules
  89. /**
  90. * Represents the status of a completed request. If `code` is
  91. * {@link grpc.status}.OK, then the request has completed successfully.
  92. * Otherwise, the request has failed, `details` will contain a description of
  93. * the error. Either way, `metadata` contains the trailing response metadata
  94. * sent by the server when it finishes processing the call.
  95. * @typedef {object} grpc~StatusObject
  96. * @property {number} code The error code, a key of {@link grpc.status}
  97. * @property {string} details Human-readable description of the status
  98. * @property {grpc.Metadata} metadata Trailing metadata sent with the status,
  99. * if applicable
  100. */
  101. /**
  102. * Describes how a request has failed. The member `message` will be the same as
  103. * `details` in {@link grpc~StatusObject}, and `code` and `metadata` are the
  104. * same as in that object.
  105. * @typedef {Error} grpc~ServiceError
  106. * @property {number} code The error code, a key of {@link grpc.status} that is
  107. * not `grpc.status.OK`
  108. * @property {grpc.Metadata} metadata Trailing metadata sent with the status,
  109. * if applicable
  110. */
  111. /**
  112. * The EventEmitter class in the event standard module
  113. * @external EventEmitter
  114. * @see https://nodejs.org/api/events.html#events_class_eventemitter
  115. */
  116. /**
  117. * The Readable class in the stream standard module
  118. * @external Readable
  119. * @see https://nodejs.org/api/stream.html#stream_readable_streams
  120. */
  121. /**
  122. * The Writable class in the stream standard module
  123. * @external Writable
  124. * @see https://nodejs.org/api/stream.html#stream_writable_streams
  125. */
  126. /**
  127. * The Duplex class in the stream standard module
  128. * @external Duplex
  129. * @see https://nodejs.org/api/stream.html#stream_class_stream_duplex
  130. */
  131. /**
  132. * A serialization function
  133. * @callback grpc~serialize
  134. * @param {*} value The value to serialize
  135. * @return {Buffer} The value serialized as a byte sequence
  136. */
  137. /**
  138. * A deserialization function
  139. * @callback grpc~deserialize
  140. * @param {Buffer} data The byte sequence to deserialize
  141. * @return {*} The data deserialized as a value
  142. */
  143. /**
  144. * The deadline of an operation. If it is a date, the deadline is reached at
  145. * the date and time specified. If it is a finite number, it is treated as
  146. * a number of milliseconds since the Unix Epoch. If it is Infinity, the
  147. * deadline will never be reached. If it is -Infinity, the deadline has already
  148. * passed.
  149. * @typedef {(number|date)} grpc~Deadline
  150. */
  151. /**
  152. * An object that completely defines a service method signature.
  153. * @typedef {Object} grpc~MethodDefinition
  154. * @property {string} path The method's URL path
  155. * @property {boolean} requestStream Indicates whether the method accepts
  156. * a stream of requests
  157. * @property {boolean} responseStream Indicates whether the method returns
  158. * a stream of responses
  159. * @property {grpc~serialize} requestSerialize Serialization
  160. * function for request values
  161. * @property {grpc~serialize} responseSerialize Serialization
  162. * function for response values
  163. * @property {grpc~deserialize} requestDeserialize Deserialization
  164. * function for request data
  165. * @property {grpc~deserialize} responseDeserialize Deserialization
  166. * function for repsonse data
  167. */
  168. /**
  169. * An object that completely defines a service.
  170. * @typedef {Object.&lt;string, grpc~MethodDefinition>} grpc~ServiceDefinition
  171. */
  172. </code></pre>
  173. </article>
  174. </section>
  175. </div>
  176. <nav>
  177. <h2><a href="index.html">Home</a></h2><h3>Externals</h3><ul><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></ul><h3>Classes</h3><ul><li><a href="grpc.Client.html">Client</a></li><li><a href="grpc.credentials-CallCredentials.html">CallCredentials</a></li><li><a href="grpc.credentials-ChannelCredentials.html">ChannelCredentials</a></li><li><a href="grpc.Metadata.html">Metadata</a></li><li><a href="grpc.Server.html">Server</a></li><li><a href="grpc.ServerCredentials.html">ServerCredentials</a></li><li><a href="grpc-ClientDuplexStream.html">ClientDuplexStream</a></li><li><a href="grpc-ClientReadableStream.html">ClientReadableStream</a></li><li><a href="grpc-ClientUnaryCall.html">ClientUnaryCall</a></li><li><a href="grpc-ClientWritableStream.html">ClientWritableStream</a></li><li><a href="grpc-ServerDuplexStream.html">ServerDuplexStream</a></li><li><a href="grpc-ServerReadableStream.html">ServerReadableStream</a></li><li><a href="grpc-ServerUnaryCall.html">ServerUnaryCall</a></li><li><a href="grpc-ServerWritableStream.html">ServerWritableStream</a></li></ul><h3>Events</h3><ul><li><a href="grpc-ClientDuplexStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientDuplexStream.html#event:status">status</a></li><li><a href="grpc-ClientReadableStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientReadableStream.html#event:status">status</a></li><li><a href="grpc-ClientUnaryCall.html#event:metadata">metadata</a></li><li><a href="grpc-ClientUnaryCall.html#event:status">status</a></li><li><a href="grpc-ClientWritableStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientWritableStream.html#event:status">status</a></li><li><a href="grpc-ServerDuplexStream.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerReadableStream.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerUnaryCall.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerWritableStream.html#~event:cancelled">cancelled</a></li></ul><h3>Namespaces</h3><ul><li><a href="grpc.html">grpc</a></li><li><a href="grpc.credentials.html">credentials</a></li></ul>
  178. </nav>
  179. <br class="clear">
  180. <footer>
  181. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Sep 08 2017 11:10:31 GMT-0700 (PDT)
  182. </footer>
  183. <script> prettyPrint(); </script>
  184. <script src="scripts/linenumber.js"> </script>
  185. </body>
  186. </html>