Skip to content

Commit

Permalink
feat: grpc keep alive settings (#2086)
Browse files Browse the repository at this point in the history
* chore: integration test fix

* chore: grpc keep alive settings
  • Loading branch information
surbhigarg92 authored Aug 2, 2024
1 parent f34f464 commit 7712c35
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 7712c35

Please sign in to comment.