OLD | NEW |
(Empty) | |
| 1 [](https://www.npmjs.com/package/gr
pc) |
| 2 # Node.js gRPC Library |
| 3 |
| 4 ## Status |
| 5 Beta |
| 6 |
| 7 ## PREREQUISITES |
| 8 - `node`: This requires `node` to be installed, version `0.12` or above. If you
instead have the `nodejs` executable on Debian, you should install the [`nodejs-
legacy`](https://packages.debian.org/sid/nodejs-legacy) package. |
| 9 |
| 10 ## INSTALLATION |
| 11 |
| 12 Install the gRPC NPM package |
| 13 |
| 14 ```sh |
| 15 npm install grpc |
| 16 ``` |
| 17 |
| 18 ## BUILD FROM SOURCE |
| 19 1. Clone [the grpc Git Repository](https://github.com/grpc/grpc). |
| 20 3. Run `npm install`. |
| 21 |
| 22 ## TESTING |
| 23 To run the test suite, simply run `npm test` in the install location. |
| 24 |
| 25 ## API |
| 26 This library internally uses [ProtoBuf.js](https://github.com/dcodeIO/ProtoBuf.j
s), and some structures it exports match those exported by that library |
| 27 |
| 28 If you require this module, you will get an object with the following members |
| 29 |
| 30 ```javascript |
| 31 function load(filename) |
| 32 ``` |
| 33 |
| 34 Takes a filename of a [Protocol Buffer](https://developers.google.com/protocol-b
uffers/) file, and returns an object representing the structure of the protocol
buffer in the following way: |
| 35 |
| 36 - Namespaces become maps from the names of their direct members to those member
objects |
| 37 - Service definitions become client constructors for clients for that service.
They also have a `service` member that can be used for constructing servers. |
| 38 - Message definitions become Message constructors like those that ProtoBuf.js w
ould create |
| 39 - Enum definitions become Enum objects like those that ProtoBuf.js would create |
| 40 - Anything else becomes the relevant reflection object that ProtoBuf.js would c
reate |
| 41 |
| 42 |
| 43 ```javascript |
| 44 function loadObject(reflectionObject) |
| 45 ``` |
| 46 |
| 47 Returns the same structure that `load` returns, but takes a reflection object fr
om `ProtoBuf.js` instead of a file name. |
| 48 |
| 49 ```javascript |
| 50 function Server([serverOpions]) |
| 51 ``` |
| 52 |
| 53 Constructs a server to which service/implementation pairs can be added. |
| 54 |
| 55 |
| 56 ```javascript |
| 57 status |
| 58 ``` |
| 59 |
| 60 An object mapping status names to status code numbers. |
| 61 |
| 62 |
| 63 ```javascript |
| 64 callError |
| 65 ``` |
| 66 |
| 67 An object mapping call error names to codes. This is primarily useful for tracki
ng down certain kinds of internal errors. |
| 68 |
| 69 |
| 70 ```javascript |
| 71 Credentials |
| 72 ``` |
| 73 |
| 74 An object with factory methods for creating credential objects for clients. |
| 75 |
| 76 |
| 77 ```javascript |
| 78 ServerCredentials |
| 79 ``` |
| 80 |
| 81 An object with factory methods for creating credential objects for servers. |
OLD | NEW |