Skip to content

Commit 7cfe40f

Browse files
WeiranFangJustinBeckwith
authored andcommitted
chore: add spanner_grpc_config.json and enable grpc-gcp support for spanner (#503)
1 parent e770252 commit 7cfe40f

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const gapic = Object.freeze({
4040
v1: require('./v1'),
4141
});
4242

43+
const gcpApiConfig = require('./spanner_grpc_config.json');
44+
4345
/*!
4446
* DO NOT DELETE THE FOLLOWING NAMESPACE DEFINITIONS
4547
*/
@@ -206,6 +208,9 @@ class Spanner extends Service {
206208
},
207209
options || {});
208210

211+
// Enable grpc-gcp support
212+
options = Object.assign({'grpc_gcp.apiConfig': gcpApiConfig}, options);
213+
209214
const config = {
210215
baseUrl: options.servicePath || gapic.v1.SpannerClient.servicePath,
211216
protosDir: path.resolve(__dirname, '../protos'),

src/spanner_grpc_config.json

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"channelPool": {
3+
"maxSize": 10,
4+
"maxConcurrentStreamsLowWatermark": 100
5+
},
6+
"method": [
7+
{
8+
"name": [ "/google.spanner.v1.Spanner/CreateSession" ],
9+
"affinity": {
10+
"command": "BIND",
11+
"affinityKey": "name"
12+
}
13+
},
14+
{
15+
"name": [ "/google.spanner.v1.Spanner/GetSession" ],
16+
"affinity": {
17+
"command": "BOUND",
18+
"affinityKey": "name"
19+
}
20+
},
21+
{
22+
"name": [ "/google.spanner.v1.Spanner/DeleteSession" ],
23+
"affinity": {
24+
"command": "UNBIND",
25+
"affinityKey": "name"
26+
}
27+
},
28+
{
29+
"name": [ "/google.spanner.v1.Spanner/ExecuteSql" ],
30+
"affinity": {
31+
"command": "BOUND",
32+
"affinityKey": "session"
33+
}
34+
},
35+
{
36+
"name": [ "/google.spanner.v1.Spanner/ExecuteStreamingSql" ],
37+
"affinity": {
38+
"command": "BOUND",
39+
"affinityKey": "session"
40+
}
41+
},
42+
{
43+
"name": [ "/google.spanner.v1.Spanner/Read" ],
44+
"affinity": {
45+
"command": "BOUND",
46+
"affinityKey": "session"
47+
}
48+
},
49+
{
50+
"name": [ "/google.spanner.v1.Spanner/StreamingRead" ],
51+
"affinity": {
52+
"command": "BOUND",
53+
"affinityKey": "session"
54+
}
55+
},
56+
{
57+
"name": [ "/google.spanner.v1.Spanner/BeginTransaction" ],
58+
"affinity": {
59+
"command": "BOUND",
60+
"affinityKey": "session"
61+
}
62+
},
63+
{
64+
"name": [ "/google.spanner.v1.Spanner/Commit" ],
65+
"affinity": {
66+
"command": "BOUND",
67+
"affinityKey": "session"
68+
}
69+
},
70+
{
71+
"name": [ "/google.spanner.v1.Spanner/Rollback" ],
72+
"affinity": {
73+
"command": "BOUND",
74+
"affinityKey": "session"
75+
}
76+
},
77+
{
78+
"name": [ "/google.spanner.v1.Spanner/PartitionQuery" ],
79+
"affinity": {
80+
"command": "BOUND",
81+
"affinityKey": "session"
82+
}
83+
},
84+
{
85+
"name": [ "/google.spanner.v1.Spanner/PartitionRead" ],
86+
"affinity": {
87+
"command": "BOUND",
88+
"affinityKey": "session"
89+
}
90+
}
91+
]
92+
}

test/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import * as pfy from '@google-cloud/promisify';
2727
import * as sinon from 'sinon';
2828
import * as spnr from '../src';
2929

30+
const apiConfig = require('../src/spanner_grpc_config.json');
31+
3032
function getFake(obj: {}) {
3133
return obj as {
3234
calledWith_: IArguments;
@@ -187,6 +189,7 @@ describe('Spanner', () => {
187189
libName: 'gccl',
188190
libVersion: require('../../package.json').version,
189191
scopes: [],
192+
'grpc_gcp.apiConfig': apiConfig,
190193
});
191194

192195
assert.deepStrictEqual(
@@ -205,6 +208,7 @@ describe('Spanner', () => {
205208
libName: 'gccl',
206209
libVersion: require('../../package.json').version,
207210
scopes: expectedScopes,
211+
'grpc_gcp.apiConfig': apiConfig,
208212
});
209213

210214
assert.deepStrictEqual(
@@ -235,6 +239,7 @@ describe('Spanner', () => {
235239
libName: 'gccl',
236240
libVersion: require('../../package.json').version,
237241
scopes: [],
242+
'grpc_gcp.apiConfig': apiConfig,
238243
}));
239244
});
240245

tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
"compilerOptions": {
44
"rootDir": ".",
55
"outDir": "build",
6-
"noImplicitAny": false
6+
"noImplicitAny": false,
7+
"resolveJsonModule": true
78
},
89
"include": [
910
"src/*.ts",
1011
"src/v1/*.d.ts",
1112
"src/**/*.js",
13+
"src/**/*.json",
1214
"test/*.ts",
1315
"system-test/*.ts",
1416
]

0 commit comments

Comments
 (0)