3 A Node.js module providing grpc supports for Google Cloud APIs.
8 npm install grpc-gcp --save
13 Let's use Spanner API as an example.
15 First, Create a json file defining API configuration, with ChannelPoolConfig and MethodConfig.
21 "maxConcurrentStreamsLowWatermark": 1
25 "name": [ "/google.spanner.v1.Spanner/CreateSession" ],
32 "name": [ "/google.spanner.v1.Spanner/GetSession" ],
39 "name": [ "/google.spanner.v1.Spanner/DeleteSession" ],
49 Load configuration to ApiConfig.
52 var grpcGcp = require('grpc-gcp');
53 var fs = require('fs');
55 var apiDefinition = JSON.parse(fs.readFileSync('your_api_config_json_file'));
56 var apiConfig = grpcGcp.createGcpApiConfig(apiDefinition);
59 Pass `gcpChannelFactoryOverride` and `gcpCallInvocationTransformer` to channel options when initializing api client.
62 var channelOptions = {
63 channelFactoryOverride: grpcGcp.gcpChannelFactoryOverride,
64 callInvocationTransformer: grpcGcp.gcpCallInvocationTransformer,
65 gcpApiConfig: apiConfig,
68 var client = new SpannerClient(
69 'spanner.googleapis.com:443',
80 git clone https://github.com/GoogleCloudPlatform/grpc-gcp-node.git && cd grpc-gcp-node
84 git submodule update --init --recursive
87 Install dependencies and build from source.
99 Setup credentials. See [Getting Started With Authentication](https://cloud.google.com/docs/authentication/getting-started) for more details.
102 export GOOGLE_APPLICATION_CREDENTIALS=path/to/key.json
111 Run integration tests.
114 npm run integration-tests