Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: grpc keep alive settings #2086

Merged
merged 11 commits into from
Aug 2, 2024
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ class Spanner extends GrpcService {
libName: 'gccl',
libVersion: require('../../package.json').version,
scopes,
// Add grpc keep alive setting
'grpc.keepalive_time_ms': 30000,
'grpc.keepalive_timeout_ms': 10000,
// Enable grpc-gcp support
'grpc.callInvocationTransformer': grpcGcp.gcpCallInvocationTransformer,
'grpc.channelFactoryOverride': grpcGcp.gcpChannelFactoryOverride,
Expand Down
20 changes: 20 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ describe('Spanner', () => {
libVersion: require('../../package.json').version,
scopes: [],
grpc,
'grpc.keepalive_time_ms': 30000,
'grpc.keepalive_timeout_ms': 10000,
'grpc.callInvocationTransformer':
fakeGrpcGcp().gcpCallInvocationTransformer,
'grpc.channelFactoryOverride': fakeGrpcGcp().gcpChannelFactoryOverride,
Expand Down Expand Up @@ -251,6 +253,24 @@ describe('Spanner', () => {
);
});

it('should override grpc settings', () => {
const keepaliveOptions = {
'grpc.keepalive_time_ms': 300,
'grpc.keepalive_timeout_ms': 100,
};
const options = extend({}, OPTIONS, keepaliveOptions);
const spanner = new Spanner(options);
const expectedOptions = Object.assign(
{},
EXPECTED_OPTIONS,
keepaliveOptions
);
assert.deepStrictEqual(
getFake(spanner.auth).calledWith_[0],
expectedOptions
);
});

it('should inherit from GrpcService', () => {
assert(spanner instanceof FakeGrpcService);

Expand Down
Loading