-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2989 from murgatroid99/gh-pages_node_beta_docs
Added node documentation
- Loading branch information
Showing
45 changed files
with
23,327 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>JSDoc: Home</title> | ||
|
||
<script src="scripts/prettify/prettify.js"> </script> | ||
<script src="scripts/prettify/lang-css.js"> </script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="main"> | ||
|
||
<h1 class="page-title">Home</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3>grpc 0.10.0</h3> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article><h1>Node.js gRPC Library</h1><h2>Status</h2><p>Alpha : Ready for early adopters</p> | ||
<h2>PREREQUISITES</h2><ul> | ||
<li><code>node</code>: This requires <code>node</code> to be installed. If you instead have the <code>nodejs</code> executable on Debian, you should install the <a href="https://packages.debian.org/sid/nodejs-legacy"><code>nodejs-legacy</code></a> package.</li> | ||
<li><a href="http://brew.sh">homebrew</a> on Mac OS X. These simplify the installation of the gRPC C core.</li> | ||
</ul> | ||
<h2>INSTALLATION</h2><p><strong>Linux (Debian):</strong></p> | ||
<p>Add <a href="https://www.debian.org/releases/stretch/">Debian testing</a> to your <code>sources.list</code> file. Example:</p> | ||
<pre class="prettyprint source lang-sh"><code>echo "deb http://ftp.us.debian.org/debian testing main contrib non-free" | \ | ||
sudo tee -a /etc/apt/sources.list</code></pre><p>Install the gRPC Debian package</p> | ||
<pre class="prettyprint source lang-sh"><code>sudo apt-get update | ||
sudo apt-get install libgrpc-dev</code></pre><p>Install the gRPC NPM package</p> | ||
<pre class="prettyprint source lang-sh"><code>npm install grpc</code></pre><p><strong>Mac OS X</strong></p> | ||
<p>Install <a href="http://brew.sh">homebrew</a>. Run the following command to install gRPC Node.js.</p> | ||
<pre class="prettyprint source lang-sh"><code>$ curl -fsSL https://goo.gl/getgrpc | bash -s nodejs</code></pre><p>This will download and run the <a href="https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install">gRPC install script</a>, then install the latest version of gRPC Nodejs npm package.</p> | ||
<h2>BUILD FROM SOURCE</h2><ol> | ||
<li>Clone <a href="https://github.com/grpc/grpc">the grpc Git Repository</a>.</li> | ||
<li>Follow the instructions in the <code>INSTALL</code> file in the root of that repository to install the C core library that this package depends on.</li> | ||
<li>Run <code>npm install</code>.</li> | ||
</ol> | ||
<p>If you install the gRPC C core library in a custom location, then you need to set some environment variables to install this library. The command will look like this:</p> | ||
<pre class="prettyprint source lang-sh"><code>CXXFLAGS=-I<custom location>/include LDFLAGS=-L<custom location>/lib npm install [grpc]</code></pre><h2>TESTING</h2><p>To run the test suite, simply run <code>npm test</code> in the install location.</p> | ||
<h2>API</h2><p>This library internally uses <a href="https://github.com/dcodeIO/ProtoBuf.js">ProtoBuf.js</a>, and some structures it exports match those exported by that library</p> | ||
<p>If you require this module, you will get an object with the following members</p> | ||
<pre class="prettyprint source lang-javascript"><code>function load(filename)</code></pre><p>Takes a filename of a <a href="https://developers.google.com/protocol-buffers/">Protocol Buffer</a> file, and returns an object representing the structure of the protocol buffer in the following way:</p> | ||
<ul> | ||
<li>Namespaces become maps from the names of their direct members to those member objects</li> | ||
<li>Service definitions become client constructors for clients for that service. They also have a <code>service</code> member that can be used for constructing servers.</li> | ||
<li>Message definitions become Message constructors like those that ProtoBuf.js would create</li> | ||
<li>Enum definitions become Enum objects like those that ProtoBuf.js would create</li> | ||
<li>Anything else becomes the relevant reflection object that ProtoBuf.js would create</li> | ||
</ul> | ||
<pre class="prettyprint source lang-javascript"><code>function loadObject(reflectionObject)</code></pre><p>Returns the same structure that <code>load</code> returns, but takes a reflection object from <code>ProtoBuf.js</code> instead of a file name.</p> | ||
<pre class="prettyprint source lang-javascript"><code>function Server([serverOpions])</code></pre><p>Constructs a server to which service/implementation pairs can be added.</p> | ||
<pre class="prettyprint source lang-javascript"><code>status</code></pre><p>An object mapping status names to status code numbers.</p> | ||
<pre class="prettyprint source lang-javascript"><code>callError</code></pre><p>An object mapping call error names to codes. This is primarily useful for tracking down certain kinds of internal errors.</p> | ||
<pre class="prettyprint source lang-javascript"><code>Credentials</code></pre><p>An object with factory methods for creating credential objects for clients.</p> | ||
<pre class="prettyprint source lang-javascript"><code>ServerCredentials</code></pre><p>An object with factory methods for creating credential objects for servers.</p></article> | ||
</section> | ||
|
||
|
||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<nav> | ||
<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_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#getClientChannel">getClientChannel</a></li><li><a href="global.html#getGoogleAuthDelegate">getGoogleAuthDelegate</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#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#Server">Server</a></li><li><a href="global.html#ServerCredentials">ServerCredentials</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> | ||
</nav> | ||
|
||
<br class="clear"> | ||
|
||
<footer> | ||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a> on Mon Aug 31 2015 11:35:11 GMT-0700 (PDT) | ||
</footer> | ||
|
||
<script> prettyPrint(); </script> | ||
<script src="scripts/linenumber.js"> </script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>JSDoc: Source: index.js</title> | ||
|
||
<script src="scripts/prettify/prettify.js"> </script> | ||
<script src="scripts/prettify/lang-css.js"> </script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="main"> | ||
|
||
<h1 class="page-title">Source: index.js</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article> | ||
<pre class="prettyprint source linenums"><code>/* | ||
* | ||
* Copyright 2015, Google Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are | ||
* met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following disclaimer | ||
* in the documentation and/or other materials provided with the | ||
* distribution. | ||
* * Neither the name of Google Inc. nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var _ = require('lodash'); | ||
|
||
var ProtoBuf = require('protobufjs'); | ||
|
||
var client = require('./src/client.js'); | ||
|
||
var server = require('./src/server.js'); | ||
|
||
var Metadata = require('./src/metadata.js'); | ||
|
||
var grpc = require('bindings')('grpc'); | ||
|
||
/** | ||
* Load a gRPC object from an existing ProtoBuf.Reflect object. | ||
* @param {ProtoBuf.Reflect.Namespace} value The ProtoBuf object to load. | ||
* @return {Object<string, *>} The resulting gRPC object | ||
*/ | ||
exports.loadObject = function loadObject(value) { | ||
var result = {}; | ||
if (value.className === 'Namespace') { | ||
_.each(value.children, function(child) { | ||
result[child.name] = loadObject(child); | ||
}); | ||
return result; | ||
} else if (value.className === 'Service') { | ||
return client.makeProtobufClientConstructor(value); | ||
} else if (value.className === 'Message' || value.className === 'Enum') { | ||
return value.build(); | ||
} else { | ||
return value; | ||
} | ||
}; | ||
|
||
var loadObject = exports.loadObject; | ||
|
||
/** | ||
* Load a gRPC object from a .proto file. | ||
* @param {string} filename The file to load | ||
* @param {string=} format The file format to expect. Must be either 'proto' or | ||
* 'json'. Defaults to 'proto' | ||
* @return {Object<string, *>} The resulting gRPC object | ||
*/ | ||
exports.load = function load(filename, format) { | ||
if (!format) { | ||
format = 'proto'; | ||
} | ||
var builder; | ||
switch(format) { | ||
case 'proto': | ||
builder = ProtoBuf.loadProtoFile(filename); | ||
break; | ||
case 'json': | ||
builder = ProtoBuf.loadJsonFile(filename); | ||
break; | ||
default: | ||
throw new Error('Unrecognized format "' + format + '"'); | ||
} | ||
|
||
return loadObject(builder.ns); | ||
}; | ||
|
||
/** | ||
* Get a function that a client can use to update metadata with authentication | ||
* information from a Google Auth credential object, which comes from the | ||
* google-auth-library. | ||
* @param {Object} credential The credential object to use | ||
* @return {function(Object, callback)} Metadata updater function | ||
*/ | ||
exports.getGoogleAuthDelegate = function getGoogleAuthDelegate(credential) { | ||
/** | ||
* Update a metadata object with authentication information. | ||
* @param {string} authURI The uri to authenticate to | ||
* @param {Object} metadata Metadata object | ||
* @param {function(Error, Object)} callback | ||
*/ | ||
return function updateMetadata(authURI, metadata, callback) { | ||
credential.getRequestMetadata(authURI, function(err, header) { | ||
if (err) { | ||
callback(err); | ||
return; | ||
} | ||
metadata.add('authorization', header.Authorization); | ||
callback(null, metadata); | ||
}); | ||
}; | ||
}; | ||
|
||
/** | ||
* @see module:src/server.Server | ||
*/ | ||
exports.Server = server.Server; | ||
|
||
/** | ||
* @see module:src/metadata | ||
*/ | ||
exports.Metadata = Metadata; | ||
|
||
/** | ||
* Status name to code number mapping | ||
*/ | ||
exports.status = grpc.status; | ||
|
||
/** | ||
* Propagate flag name to number mapping | ||
*/ | ||
exports.propagate = grpc.propagate; | ||
|
||
/** | ||
* Call error name to code number mapping | ||
*/ | ||
exports.callError = grpc.callError; | ||
|
||
/** | ||
* Write flag name to code number mapping | ||
*/ | ||
exports.writeFlags = grpc.writeFlags; | ||
|
||
/** | ||
* Credentials factories | ||
*/ | ||
exports.Credentials = grpc.Credentials; | ||
|
||
/** | ||
* ServerCredentials factories | ||
*/ | ||
exports.ServerCredentials = grpc.ServerCredentials; | ||
|
||
/** | ||
* @see module:src/client.makeClientConstructor | ||
*/ | ||
exports.makeGenericClientConstructor = client.makeClientConstructor; | ||
|
||
/** | ||
* @see module:src/client.getClientChannel | ||
*/ | ||
exports.getClientChannel = client.getClientChannel; | ||
|
||
/** | ||
* @see module:src/client.waitForClientReady | ||
*/ | ||
exports.waitForClientReady = client.waitForClientReady; | ||
</code></pre> | ||
</article> | ||
</section> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<nav> | ||
<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_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#getClientChannel">getClientChannel</a></li><li><a href="global.html#getGoogleAuthDelegate">getGoogleAuthDelegate</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#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#Server">Server</a></li><li><a href="global.html#ServerCredentials">ServerCredentials</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> | ||
</nav> | ||
|
||
<br class="clear"> | ||
|
||
<footer> | ||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a> on Mon Aug 31 2015 11:35:11 GMT-0700 (PDT) | ||
</footer> | ||
|
||
<script> prettyPrint(); </script> | ||
<script src="scripts/linenumber.js"> </script> | ||
</body> | ||
</html> |
Oops, something went wrong.