mirror of https://github.com/grpc/grpc-node.git
2.0 KiB
2.0 KiB
Pure JavaScript gRPC Client
Installation
Node 12 is recommended. The exact set of compatible Node versions can be found in the engines field of the package.json file.
npm install @grpc/grpc-js
Features
- Clients
- Automatic reconnection
- Servers
- Streaming
- Metadata
- Partial compression support: clients can decompress response messages
- Pick first and round robin load balancing policies
- Client Interceptors
- Connection Keepalives
- HTTP Connect support (proxies)
This library does not directly handle .proto files. To use .proto files with this library we recommend using the @grpc/proto-loader package.
Migrating from grpc
@grpc/grpc-js is almost a drop-in replacement for grpc, but you may need to make a few code changes to use it:
- If you are currently loading
.protofiles usinggrpc.load, that function is not available in this library. You should instead load your.protofiles using@grpc/proto-loaderand load the resulting package definition objects into@grpc/grpc-jsusinggrpc.loadPackageDefinition. - If you are currently loading packages generated by
grpc-tools, you should instead generate your files using the--generate_package_definitionsoption ingrpc-tools, then load the object exported by the generated file into@grpc/grpc-jsusinggrpc.loadPackageDefinition. - If you have a server and you are using
Server#bindto bind ports, you will need to useServer#bindAsyncinstead.
Some Notes on API Guarantees
The public API of this library follows semantic versioning, with some caveats:
- Some methods are prefixed with an underscore. These methods are internal and should not be considered part of the public API.
- The class
Callis only exposed due to limitations of TypeScript. It should not be considered part of the public API. - In general, any API that is exposed by this library but is not exposed by the
grpclibrary is likely an error and should not be considered part of the public API.